Fix completion of builtins and a piece of slightly overcomplicated logic
This commit is contained in:
parent
4198edbdaa
commit
8d34232c7a
@ -382,26 +382,26 @@ fn refreshDocument(self: *DocumentStore, handle: *Handle, zig_lib_path: ?[]const
|
|||||||
for (import_strs.items) |str| {
|
for (import_strs.items) |str| {
|
||||||
const uri = (try self.uriFromImportStr(&arena.allocator, handle.*, str)) orelse continue;
|
const uri = (try self.uriFromImportStr(&arena.allocator, handle.*, str)) orelse continue;
|
||||||
|
|
||||||
var idx: usize = 0;
|
exists_loop: for (still_exist) |*does_still_exist, i| {
|
||||||
exists_loop: while (idx < still_exist.len) : (idx += 1) {
|
if (does_still_exist.*) continue;
|
||||||
if (still_exist[idx]) continue;
|
|
||||||
|
|
||||||
if (std.mem.eql(u8, handle.import_uris.items[idx], uri)) {
|
if (std.mem.eql(u8, handle.import_uris.items[i], uri)) {
|
||||||
still_exist[idx] = true;
|
does_still_exist.* = true;
|
||||||
break :exists_loop;
|
break :exists_loop;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Go through still_exist, remove the items that are false and decrement their handle counts.
|
// Go through still_exist, remove the items that are false and decrement their handle counts.
|
||||||
var offset: usize = 0;
|
|
||||||
var idx: usize = 0;
|
var idx: usize = 0;
|
||||||
while (idx < still_exist.len) : (idx += 1) {
|
for (still_exist) |does_still_exist| {
|
||||||
if (still_exist[idx]) continue;
|
if (does_still_exist) {
|
||||||
|
idx += 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
log.debug("Import removed: {s}", .{handle.import_uris.items[idx - offset]});
|
log.debug("Import removed: {s}", .{handle.import_uris.items[idx]});
|
||||||
const uri = handle.import_uris.orderedRemove(idx - offset);
|
const uri = handle.import_uris.orderedRemove(idx);
|
||||||
offset += 1;
|
|
||||||
|
|
||||||
self.decrementCount(uri);
|
self.decrementCount(uri);
|
||||||
self.allocator.free(uri);
|
self.allocator.free(uri);
|
||||||
|
@ -1027,10 +1027,10 @@ fn completeBuiltin(arena: *std.heap.ArenaAllocator, id: types.RequestId, config:
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (config.enable_snippets) {
|
if (config.enable_snippets) {
|
||||||
builtin_completions.?[idx].insertText = builtin.snippet[1..];
|
builtin_completions.?[idx].insertText = builtin.snippet;
|
||||||
builtin_completions.?[idx].insertTextFormat = .Snippet;
|
builtin_completions.?[idx].insertTextFormat = .Snippet;
|
||||||
} else {
|
} else {
|
||||||
builtin_completions.?[idx].insertText = builtin.name[1..];
|
builtin_completions.?[idx].insertText = builtin.name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user