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");