Don't complete inside comments (#171)

This commit is contained in:
rszyma
2025-07-01 05:48:14 +02:00
committed by GitHub
parent 88ae93bae1
commit b043bfe1f3

View File

@@ -158,9 +158,11 @@ pub(crate) fn completions(
impl Context<'_> {
fn complete(&mut self) -> Option<()> {
// Do not complete inside strings.
// Do not complete inside strings or comments.
// TODO: Escapes and `${}` snippets?
if let T!["''"] | T!['"'] | SyntaxKind::STRING_FRAGMENT = self.token.kind() {
if let T!["''"] | T!['"'] | SyntaxKind::STRING_FRAGMENT | SyntaxKind::COMMENT =
self.token.kind()
{
return None;
}
@@ -1054,4 +1056,12 @@ stdenv.mkDerivation {
expect!["(Param) { foo, bar ? foo }: 42"],
);
}
#[test]
fn no_inside_comment() {
check_no("# l$0", "let");
check_no("/* l$0 */", "let");
check_no("let abc = 1; in # ab$0", "abc");
check_no("let abc = 1; in /* ab$0 */", "abc");
}
}