From 3ca6f2a19e5b77c81c7dd394c1b0d8d20870b152 Mon Sep 17 00:00:00 2001 From: Techatrix Date: Wed, 15 Jan 2025 18:11:41 +0100 Subject: [PATCH] fix goto definition on the string literal inside `@import` --- src/features/goto.zig | 2 +- tests/utility/position_context.zig | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/features/goto.zig b/src/features/goto.zig index f05e5799b..1a6b198b9 100644 --- a/src/features/goto.zig +++ b/src/features/goto.zig @@ -188,7 +188,7 @@ fn gotoDefinitionString( const tracy_zone = tracy.trace(@src()); defer tracy_zone.end(); - const loc = pos_context.loc().?; + const loc = pos_context.stringLiteralContentLoc(handle.tree.source); if (loc.start == loc.end) return null; const import_str = offsets.locToSlice(handle.tree.source, loc); diff --git a/tests/utility/position_context.zig b/tests/utility/position_context.zig index 22639501c..462dfe6cd 100644 --- a/tests/utility/position_context.zig +++ b/tests/utility/position_context.zig @@ -286,12 +286,18 @@ test "import/embedfile string literal" { try testContext( \\const std = @import("st"); , .import_string_literal, .{ .lookahead = false }); + try testContext( + \\const std = @import("st"); + , .import_string_literal, .{ .lookahead = true }); try testContext( \\const std = @embedFile("file."); , .embedfile_string_literal, .{ .lookahead = false }); try testContext( \\const std = @embedFile("file."); , .embedfile_string_literal, .{ .lookahead = false }); + try testContext( + \\const std = @embedFile("file."); + , .embedfile_string_literal, .{ .lookahead = true }); try testContext( \\const std = @import("std");