From 2eab5e036d346e4ca0fe421e0bbe3519abdf0ac4 Mon Sep 17 00:00:00 2001 From: Alexandros Naskos Date: Thu, 21 May 2020 20:51:03 +0300 Subject: [PATCH 1/2] Check that the goto definition cursor is within bounds --- src/main.zig | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main.zig b/src/main.zig index c4c7a76..709447a 100644 --- a/src/main.zig +++ b/src/main.zig @@ -283,6 +283,7 @@ fn nodeToCompletion(list: *std.ArrayList(types.CompletionItem), analysis_ctx: *D } fn identifierFromPosition(pos_index: usize, handle: DocumentStore.Handle) []const u8 { + if (pos_index + 1 >= handle.document.text.len) return &[0]u8{}; var start_idx = pos_index; while (start_idx > 0 and From ccc923e2f0831349e2e15974b51f327094d85d49 Mon Sep 17 00:00:00 2001 From: Alexandros Naskos Date: Thu, 21 May 2020 21:02:12 +0300 Subject: [PATCH 2/2] One more fix --- src/main.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.zig b/src/main.zig index 709447a..ec21821 100644 --- a/src/main.zig +++ b/src/main.zig @@ -291,7 +291,7 @@ fn identifierFromPosition(pos_index: usize, handle: DocumentStore.Handle) []cons {} var end_idx = pos_index; - while (end_idx < handle.document.text.len and + while (end_idx < handle.document.text.len - 1 and (std.ascii.isAlNum(handle.document.text[end_idx]) or handle.document.text[end_idx] == '_')) : (end_idx += 1) {}