Skip to content

Commit

Permalink
fix: issue #87
Browse files Browse the repository at this point in the history
  • Loading branch information
elijah-potter committed Jul 6, 2024
1 parent 8eac6bc commit f7ea74e
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion harper-comments/tests/language_support.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
5 changes: 3 additions & 2 deletions harper-comments/tests/language_support_sources/jsdoc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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} */
1 change: 0 additions & 1 deletion harper-ls/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
4 changes: 3 additions & 1 deletion harper-ls/src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,9 @@ impl Backend {

#[tower_lsp::async_trait]
impl LanguageServer for Backend {
async fn initialize(&self, _: InitializeParams) -> Result<InitializeResult> {
async fn initialize(&self, p: InitializeParams) -> Result<InitializeResult> {
dbg!(p.capabilities);

Ok(InitializeResult {
server_info: None,
capabilities: ServerCapabilities {
Expand Down
5 changes: 2 additions & 3 deletions harper-ls/src/pos_conv.rs
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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 {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit f7ea74e

Please sign in to comment.