internal: deduplicate

This commit is contained in:
Aleksey Kladov
2021-09-04 12:56:34 +03:00
parent 33199b7e43
commit 2d2c4e7c22
5 changed files with 55 additions and 33 deletions

View File

@@ -21,7 +21,9 @@ use crate::{
config::Config,
global_state::GlobalStateSnapshot,
line_index::{LineEndings, LineIndex, OffsetEncoding},
lsp_ext, semantic_tokens, Result,
lsp_ext,
lsp_utils::invalid_params_error,
semantic_tokens, Result,
};
pub(crate) fn position(line_index: &LineIndex, offset: TextSize) -> lsp_types::Position {
@@ -1198,7 +1200,9 @@ pub(crate) fn markup_content(markup: Markup) -> lsp_types::MarkupContent {
}
pub(crate) fn rename_error(err: RenameError) -> crate::LspError {
crate::LspError { code: lsp_server::ErrorCode::InvalidParams as i32, message: err.to_string() }
// This is wrong, but we don't have a better alternative I suppose?
// https://github.com/microsoft/language-server-protocol/issues/1341
invalid_params_error(err.to_string())
}
#[cfg(test)]