diff --git a/src/main.zig b/src/main.zig index 66a2508..65b0d24 100644 --- a/src/main.zig +++ b/src/main.zig @@ -559,7 +559,7 @@ pub fn identifierFromPosition(pos_index: usize, handle: DocumentStore.Handle) [] if (pos_index + 1 >= text.len) return &[0]u8{}; var start_idx = pos_index; - while (start_idx > 0 and isSymbolChar(text[start_idx-1])) { + while (start_idx > 0 and isSymbolChar(text[start_idx - 1])) { start_idx -= 1; } @@ -569,7 +569,7 @@ pub fn identifierFromPosition(pos_index: usize, handle: DocumentStore.Handle) [] } if (end_idx <= start_idx) return &[0]u8{}; - return text[start_idx .. end_idx]; + return text[start_idx..end_idx]; } fn isSymbolChar(char: u8) bool { return std.ascii.isAlNum(char) or char == '_'; diff --git a/src/semantic_tokens.zig b/src/semantic_tokens.zig index 17d9c54..5374340 100644 --- a/src/semantic_tokens.zig +++ b/src/semantic_tokens.zig @@ -136,6 +136,9 @@ const Builder = struct { /// Highlight normal comments and doc comments. fn handleComments(self: *Builder, from: usize, to: usize) !void { + if (from == to) return; + std.debug.assert(from < to); + const source = self.handle.tree.source; var i: usize = from; diff --git a/tests/sessions.zig b/tests/sessions.zig index 8d75cbf..c5ad3a4 100644 --- a/tests/sessions.zig +++ b/tests/sessions.zig @@ -73,7 +73,6 @@ const Server = struct { const result = ",\"result\":"; const msg = rest[id_end + result.len .. rest.len - 1]; - if (std.mem.eql(u8, msg, expected)) { return; } else { @@ -108,7 +107,7 @@ const Server = struct { fn startZls() !*std.ChildProcess { std.debug.print("\n", .{}); - var process = try std.ChildProcess.init(&[_][]const u8{"zig-out/bin/zls" ++ suffix}, allocator); + var process = try std.ChildProcess.init(&[_][]const u8{"zig-cache/bin/zls" ++ suffix}, allocator); process.stdin_behavior = .Pipe; process.stdout_behavior = .Pipe; process.stderr_behavior = .Pipe; //std.ChildProcess.StdIo.Inherit;