From f7ea74eca796ddd5f61f9996b43108766615511a Mon Sep 17 00:00:00 2001 From: Elijah Potter Date: Sat, 6 Jul 2024 11:16:37 -0600 Subject: [PATCH] fix: issue #87 --- Cargo.lock | 1 - harper-comments/tests/language_support.rs | 2 +- harper-comments/tests/language_support_sources/jsdoc.ts | 5 +++-- harper-ls/Cargo.toml | 1 - harper-ls/src/backend.rs | 4 +++- harper-ls/src/pos_conv.rs | 5 ++--- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d6fca02c..b88803c0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -615,7 +615,6 @@ dependencies = [ "tower-lsp", "tracing", "tracing-subscriber", - "unicode-width", ] [[package]] diff --git a/harper-comments/tests/language_support.rs b/harper-comments/tests/language_support.rs index 180a864f..228d173e 100644 --- a/harper-comments/tests/language_support.rs +++ b/harper-comments/tests/language_support.rs @@ -38,5 +38,5 @@ macro_rules! create_test { create_test!(multiline_comments.cpp, 3); create_test!(multiline_comments.ts, 3); create_test!(clean.rs, 0); -create_test!(jsdoc.ts, 2); +create_test!(jsdoc.ts, 3); create_test!(issue_96.lua, 0); diff --git a/harper-comments/tests/language_support_sources/jsdoc.ts b/harper-comments/tests/language_support_sources/jsdoc.ts index ccf83da3..c684017b 100644 --- a/harper-comments/tests/language_support_sources/jsdoc.ts +++ b/harper-comments/tests/language_support_sources/jsdoc.ts @@ -2,9 +2,10 @@ * Since there are no keywords it _sould_ be checked. */ function test(){} -/** @class this sould be unchecked. */ +/** This is also a doc comment. + * @class this sould be unchecked. */ class Clazz { } -/** Here is another example: {@link this sould also b unchecked} */ +/** Here is another example: {@link this sould also b unchecked}. But this _sould_ be.*/ /** However, tis should be checked, while {@link tis should not} */ diff --git a/harper-ls/Cargo.toml b/harper-ls/Cargo.toml index 93ceff6f..6c9d8315 100644 --- a/harper-ls/Cargo.toml +++ b/harper-ls/Cargo.toml @@ -23,5 +23,4 @@ tracing-subscriber = "0.3.18" resolve-path = "0.1.0" open = "5.1.1" futures = "0.3.30" -unicode-width = "0.1.11" serde = { version = "1.0.197", features = ["derive"] } diff --git a/harper-ls/src/backend.rs b/harper-ls/src/backend.rs index bc16cf53..509c4923 100644 --- a/harper-ls/src/backend.rs +++ b/harper-ls/src/backend.rs @@ -349,7 +349,9 @@ impl Backend { #[tower_lsp::async_trait] impl LanguageServer for Backend { - async fn initialize(&self, _: InitializeParams) -> Result { + async fn initialize(&self, p: InitializeParams) -> Result { + dbg!(p.capabilities); + Ok(InitializeResult { server_info: None, capabilities: ServerCapabilities { diff --git a/harper-ls/src/pos_conv.rs b/harper-ls/src/pos_conv.rs index ad00a53f..760eeaaf 100644 --- a/harper-ls/src/pos_conv.rs +++ b/harper-ls/src/pos_conv.rs @@ -1,6 +1,5 @@ use harper_core::Span; use tower_lsp::lsp_types::{Position, Range}; -use unicode_width::UnicodeWidthChar; /// This module includes various conversions from the index-based [`Span`]s that /// Harper uses, and the Ranges that the LSP uses. @@ -26,7 +25,7 @@ fn index_to_position(source: &[char], index: usize) -> Position { let cols: usize = source[last_newline_idx..index] .iter() - .map(|c| c.width().unwrap_or(0)) + .map(|c| c.len_utf16()) .sum(); Position { @@ -54,7 +53,7 @@ fn position_to_index(source: &[char], position: Position) -> usize { return line_start_idx + traversed_chars; } - traversed_cols += c.width().unwrap_or(0); + traversed_cols += c.len_utf16(); } line_start_idx