Skip to content

Commit 83ae7b1

Browse files
committed
provide top level snippet completions even after the first character
1 parent 173ad11 commit 83ae7b1

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/features/completions.zig

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -859,11 +859,9 @@ pub fn completionAtIndex(
859859
};
860860
const source = handle.tree.source;
861861

862-
// Provide `top_level_decl_data` only if `offsets.lineSliceUntilIndex(handle.tree.source, source_index).len` is
863-
// 0 => Empty new line, manually triggered
864-
// 1 => This is the very first char on a given line
865-
const at_line_start = offsets.lineSliceUntilIndex(source, source_index).len < 2;
866-
if (at_line_start) {
862+
const line_until_index = offsets.lineSliceUntilIndex(source, source_index);
863+
864+
if (line_until_index.len == 0 or std.zig.isValidId(line_until_index)) {
867865
try populateSnippedCompletions(&builder, &snipped_data.top_level_decl_data);
868866
return .{ .isIncomplete = false, .items = builder.completions.items };
869867
}

0 commit comments

Comments
 (0)