diff options
author | Aleksey Kladov <[email protected]> | 2021-02-12 22:26:01 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2021-02-16 16:17:32 +0000 |
commit | f3d56b89c54110aaafab14eeaa4c803abe10b7df (patch) | |
tree | 2425411886ff7b647cc8938d5b7c6e3105989d99 /crates/rust-analyzer/src/config.rs | |
parent | c8b9ec8e62d9f560a6557496bc4b579019ccb509 (diff) |
Enable offset-encoding capability
Diffstat (limited to 'crates/rust-analyzer/src/config.rs')
-rw-r--r-- | crates/rust-analyzer/src/config.rs | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/crates/rust-analyzer/src/config.rs b/crates/rust-analyzer/src/config.rs index f9098968a..425ef145c 100644 --- a/crates/rust-analyzer/src/config.rs +++ b/crates/rust-analyzer/src/config.rs | |||
@@ -23,7 +23,10 @@ use rustc_hash::FxHashSet; | |||
23 | use serde::{de::DeserializeOwned, Deserialize}; | 23 | use serde::{de::DeserializeOwned, Deserialize}; |
24 | use vfs::AbsPathBuf; | 24 | use vfs::AbsPathBuf; |
25 | 25 | ||
26 | use crate::{caps::completion_item_edit_resolve, diagnostics::DiagnosticsMapConfig}; | 26 | use crate::{ |
27 | caps::completion_item_edit_resolve, diagnostics::DiagnosticsMapConfig, | ||
28 | line_endings::OffsetEncoding, lsp_ext::supports_utf8, | ||
29 | }; | ||
27 | 30 | ||
28 | config_data! { | 31 | config_data! { |
29 | struct ConfigData { | 32 | struct ConfigData { |
@@ -415,6 +418,13 @@ impl Config { | |||
415 | false | 418 | false |
416 | ) | 419 | ) |
417 | } | 420 | } |
421 | pub fn offset_encoding(&self) -> OffsetEncoding { | ||
422 | if supports_utf8(&self.caps) { | ||
423 | OffsetEncoding::Utf8 | ||
424 | } else { | ||
425 | OffsetEncoding::Utf16 | ||
426 | } | ||
427 | } | ||
418 | 428 | ||
419 | fn experimental(&self, index: &'static str) -> bool { | 429 | fn experimental(&self, index: &'static str) -> bool { |
420 | try_or!(self.caps.experimental.as_ref()?.get(index)?.as_bool()?, false) | 430 | try_or!(self.caps.experimental.as_ref()?.get(index)?.as_bool()?, false) |