Skip to content

Commit

Permalink
Merge pull request #7374 from JRI98/fix_language_server_utf8
Browse files Browse the repository at this point in the history
Fix language server crash on UTF-8 completion
  • Loading branch information
smores56 authored Dec 15, 2024
2 parents a1d61c5 + 44aec50 commit edd7c65
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
5 changes: 5 additions & 0 deletions crates/language_server/src/analysis/analysed_doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ impl DocInfo {
.rev()
.take_while(|&a| is_roc_identifier_char(&(*a as char)))
.count();

if symbol_len == 0 {
return String::from("");
}

let symbol = &self.source[offset - symbol_len..offset];

String::from(symbol)
Expand Down
24 changes: 24 additions & 0 deletions crates/language_server/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -620,4 +620,28 @@ mod tests {
"#]]
.assert_debug_eq(&actual);
}

#[tokio::test]
async fn test_completion_on_utf8() {
let actual = completion_test(
indoc! {r"
main =
"},
"ç",
Position::new(4, 3),
)
.await;

expect![[r#"
Some(
[
(
"main",
None,
),
],
)
"#]]
.assert_debug_eq(&actual);
}
}

0 comments on commit edd7c65

Please sign in to comment.