mirror of
https://github.com/Myriad-Dreamin/tinymist.git
synced 2025-11-22 20:35:20 +00:00
fix: set position_encoding on handshake and fix to utf-16 (#2153)
Some checks failed
tinymist::auto_tag / auto-tag (push) Has been cancelled
tinymist::ci / Duplicate Actions Detection (push) Has been cancelled
tinymist::ci / Check Clippy, Formatting, Completion, Documentation, and Tests (Linux) (push) Has been cancelled
tinymist::ci / Check Minimum Rust version and Tests (Windows) (push) Has been cancelled
tinymist::ci / prepare-build (push) Has been cancelled
tinymist::gh_pages / build-gh-pages (push) Has been cancelled
tinymist::ci / announce (push) Has been cancelled
tinymist::ci / build (push) Has been cancelled
Some checks failed
tinymist::auto_tag / auto-tag (push) Has been cancelled
tinymist::ci / Duplicate Actions Detection (push) Has been cancelled
tinymist::ci / Check Clippy, Formatting, Completion, Documentation, and Tests (Linux) (push) Has been cancelled
tinymist::ci / Check Minimum Rust version and Tests (Windows) (push) Has been cancelled
tinymist::ci / prepare-build (push) Has been cancelled
tinymist::gh_pages / build-gh-pages (push) Has been cancelled
tinymist::ci / announce (push) Has been cancelled
tinymist::ci / build (push) Has been cancelled
Although we don't have enough tests about utf-8 position encoding, i.e. it is not good to decide to use utf-8, it is completely wrong to not passing a decided encoding back to client on initialization. Edit: it doesn't work correctly under utf-8, so we currently always use utf-16. We may fix it in v0.14
This commit is contained in:
parent
cee5bfa4e6
commit
2c198a3d6a
7 changed files with 23 additions and 16 deletions
|
|
@ -769,18 +769,22 @@ impl Default for ConstConfig {
|
|||
|
||||
impl From<&InitializeParams> for ConstConfig {
|
||||
fn from(params: &InitializeParams) -> Self {
|
||||
const DEFAULT_ENCODING: &[PositionEncodingKind] = &[PositionEncodingKind::UTF16];
|
||||
// const DEFAULT_ENCODING: &[PositionEncodingKind] =
|
||||
// &[PositionEncodingKind::UTF16];
|
||||
|
||||
// todo: respect position encoding.
|
||||
let position_encoding = {
|
||||
let general = params.capabilities.general.as_ref();
|
||||
let encodings = try_(|| Some(general?.position_encodings.as_ref()?.as_slice()));
|
||||
let encodings = encodings.unwrap_or(DEFAULT_ENCODING);
|
||||
// let general = params.capabilities.general.as_ref();
|
||||
// let encodings = try_(||
|
||||
// Some(general?.position_encodings.as_ref()?.as_slice()));
|
||||
// let encodings = encodings.unwrap_or(DEFAULT_ENCODING);
|
||||
|
||||
if encodings.contains(&PositionEncodingKind::UTF8) {
|
||||
PositionEncoding::Utf8
|
||||
} else {
|
||||
PositionEncoding::Utf16
|
||||
}
|
||||
// if encodings.contains(&PositionEncodingKind::UTF8) {
|
||||
// PositionEncoding::Utf8
|
||||
// } else {
|
||||
// PositionEncoding::Utf16
|
||||
// }
|
||||
PositionEncoding::Utf16
|
||||
};
|
||||
|
||||
let workspace = params.capabilities.workspace.as_ref();
|
||||
|
|
|
|||
|
|
@ -123,8 +123,7 @@ impl Initializer for SuperInit {
|
|||
|
||||
let res = InitializeResult {
|
||||
capabilities: ServerCapabilities {
|
||||
// todo: respect position_encoding
|
||||
// position_encoding: Some(cc.position_encoding.into()),
|
||||
position_encoding: Some(const_config.position_encoding.into()),
|
||||
hover_provider: Some(HoverProviderCapability::Simple(true)),
|
||||
signature_help_provider: Some(SignatureHelpOptions {
|
||||
trigger_characters: Some(vec![
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue