Merge #7657
7657: utf8 r=matklad a=matklad - Prepare for utf-8 offsets - reduce code duplication in tests - Make utf8 default, implement utf16 in terms of it - Make it easy to add additional context for offset conversion - Implement utf8 offsets closes #7453 Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
@@ -23,7 +23,10 @@ use rustc_hash::FxHashSet;
|
||||
use serde::{de::DeserializeOwned, Deserialize};
|
||||
use vfs::AbsPathBuf;
|
||||
|
||||
use crate::{caps::completion_item_edit_resolve, diagnostics::DiagnosticsMapConfig};
|
||||
use crate::{
|
||||
caps::completion_item_edit_resolve, diagnostics::DiagnosticsMapConfig,
|
||||
line_index::OffsetEncoding, lsp_ext::supports_utf8,
|
||||
};
|
||||
|
||||
config_data! {
|
||||
struct ConfigData {
|
||||
@@ -415,6 +418,13 @@ impl Config {
|
||||
false
|
||||
)
|
||||
}
|
||||
pub fn offset_encoding(&self) -> OffsetEncoding {
|
||||
if supports_utf8(&self.caps) {
|
||||
OffsetEncoding::Utf8
|
||||
} else {
|
||||
OffsetEncoding::Utf16
|
||||
}
|
||||
}
|
||||
|
||||
fn experimental(&self, index: &'static str) -> bool {
|
||||
try_or!(self.caps.experimental.as_ref()?.get(index)?.as_bool()?, false)
|
||||
|
||||
Reference in New Issue
Block a user