Merge pull request #72 from alexnask/master
Check that the goto definition cursor is within bounds
This commit is contained in:
commit
ef7dea8104
@ -283,6 +283,7 @@ fn nodeToCompletion(list: *std.ArrayList(types.CompletionItem), analysis_ctx: *D
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn identifierFromPosition(pos_index: usize, handle: DocumentStore.Handle) []const u8 {
|
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;
|
var start_idx = pos_index;
|
||||||
|
|
||||||
while (start_idx > 0 and
|
while (start_idx > 0 and
|
||||||
@ -290,7 +291,7 @@ fn identifierFromPosition(pos_index: usize, handle: DocumentStore.Handle) []cons
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
var end_idx = pos_index;
|
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)
|
(std.ascii.isAlNum(handle.document.text[end_idx]) or handle.document.text[end_idx] == '_')) : (end_idx += 1)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user