From 17a4f9ea4545820cde2a908f2ecb69c3b3f636a9 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Wed, 22 Oct 2025 09:20:37 -0700 Subject: [PATCH 1/5] Handle nil end position in getMappedLocation --- internal/fourslash/_scripts/failingTests.txt | 1 - .../gen/findAllRefsForDefaultExport03_test.go | 2 +- internal/ls/source_map.go | 6 + .../findAllRefsForModule.baseline.jsonc | 9 + .../getOccurrencesIfElseBroken.baseline.jsonc | 57 ++++ ...ndAllRefsForDefaultExport03.baseline.jsonc | 141 +++++++++ .../findAllRefsForModule.baseline.jsonc | 33 +++ ...findAllRefsModuleDotExports.baseline.jsonc | 3 + ...erencesForStatementKeywords.baseline.jsonc | 268 ++++++++++++++++++ 9 files changed, 518 insertions(+), 2 deletions(-) create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/findAllRefsForModule.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesIfElseBroken.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForDefaultExport03.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForModule.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/findAllReferences/findAllRefsModuleDotExports.baseline.jsonc create mode 100644 testdata/baselines/reference/fourslash/findAllReferences/referencesForStatementKeywords.baseline.jsonc diff --git a/internal/fourslash/_scripts/failingTests.txt b/internal/fourslash/_scripts/failingTests.txt index 1db2b09ce7..09435b6337 100644 --- a/internal/fourslash/_scripts/failingTests.txt +++ b/internal/fourslash/_scripts/failingTests.txt @@ -167,7 +167,6 @@ TestDoubleUnderscoreCompletions TestEditJsdocType TestExportDefaultClass TestExportDefaultFunction -TestFindAllRefsForDefaultExport03 TestFindAllRefsForModule TestFindAllRefsModuleDotExports TestFindReferencesBindingPatternInJsdocNoCrash1 diff --git a/internal/fourslash/tests/gen/findAllRefsForDefaultExport03_test.go b/internal/fourslash/tests/gen/findAllRefsForDefaultExport03_test.go index f41ebfe43a..85578f9b73 100644 --- a/internal/fourslash/tests/gen/findAllRefsForDefaultExport03_test.go +++ b/internal/fourslash/tests/gen/findAllRefsForDefaultExport03_test.go @@ -9,7 +9,7 @@ import ( func TestFindAllRefsForDefaultExport03(t *testing.T) { t.Parallel() - t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") const content = `/*1*/function /*2*/f() { return 100; diff --git a/internal/ls/source_map.go b/internal/ls/source_map.go index 62eafda161..c970070558 100644 --- a/internal/ls/source_map.go +++ b/internal/ls/source_map.go @@ -18,6 +18,12 @@ func (l *LanguageService) getMappedLocation(fileName string, fileRange core.Text } } endPos := l.tryGetSourcePosition(fileName, core.TextPos(fileRange.End())) + if endPos == nil { + endPos = &sourcemap.DocumentPosition{ + FileName: startPos.FileName, + Pos: startPos.Pos + fileRange.Len(), + } + } debug.Assert(endPos.FileName == startPos.FileName, "start and end should be in same file") newRange := core.NewTextRange(startPos.Pos, endPos.Pos) lspRange := l.createLspRangeFromRange(newRange, l.getScript(startPos.FileName)) diff --git a/testdata/baselines/reference/fourslash/documentHighlights/findAllRefsForModule.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/findAllRefsForModule.baseline.jsonc new file mode 100644 index 0000000000..35e8e3f07c --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/findAllRefsForModule.baseline.jsonc @@ -0,0 +1,9 @@ +// === documentHighlights === +// === /b.ts === +// import { x } from "/*HIGHLIGHTS*/[|./a|]"; + + + +// === documentHighlights === +// === /c/sub.js === +// const a = require("/*HIGHLIGHTS*/[|../a|]"); \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesIfElseBroken.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesIfElseBroken.baseline.jsonc new file mode 100644 index 0000000000..c1c381e16a --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesIfElseBroken.baseline.jsonc @@ -0,0 +1,57 @@ +// === documentHighlights === +// === /getOccurrencesIfElseBroken.ts === +// /*HIGHLIGHTS*/[|if|] (true) { +// var x = 1; +// } +// [|else if|] () +// [|else if|] +// [|else|] /* whar garbl */ [|if|] (if (true) { } else { }) +// else + + + +// === documentHighlights === +// === /getOccurrencesIfElseBroken.ts === +// [|if|] (true) { +// var x = 1; +// } +// /*HIGHLIGHTS*/[|else if|] () +// [|else if|] +// [|else|] /* whar garbl */ [|if|] (if (true) { } else { }) +// else + + + +// === documentHighlights === +// === /getOccurrencesIfElseBroken.ts === +// [|if|] (true) { +// var x = 1; +// } +// [|else if|] () +// /*HIGHLIGHTS*/[|else if|] +// [|else|] /* whar garbl */ [|if|] (if (true) { } else { }) +// else + + + +// === documentHighlights === +// === /getOccurrencesIfElseBroken.ts === +// [|if|] (true) { +// var x = 1; +// } +// [|else if|] () +// [|else if|] +// /*HIGHLIGHTS*/[|else|] /* whar garbl */ [|if|] (if (true) { } else { }) +// else + + + +// === documentHighlights === +// === /getOccurrencesIfElseBroken.ts === +// [|if|] (true) { +// var x = 1; +// } +// [|else if|] () +// [|else if|] +// [|else|] /* whar garbl */ /*HIGHLIGHTS*/[|if|] (if (true) { } else { }) +// else \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForDefaultExport03.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForDefaultExport03.baseline.jsonc new file mode 100644 index 0000000000..137945bf4a --- /dev/null +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForDefaultExport03.baseline.jsonc @@ -0,0 +1,141 @@ +// === findAllReferences === +// === /findAllRefsForDefaultExport03.ts === +// /*FIND ALL REFS*/function [|f|]() { +// return 100; +// } +// +// export default [|f|]; +// +// var x: typeof [|f|]; +// +// var y = [|f|](); +// +// namespace [|f|] { +// var local = 100; +// } + + + +// === findAllReferences === +// === /findAllRefsForDefaultExport03.ts === +// function /*FIND ALL REFS*/[|f|]() { +// return 100; +// } +// +// export default [|f|]; +// +// var x: typeof [|f|]; +// +// var y = [|f|](); +// +// namespace [|f|] { +// var local = 100; +// } + + + +// === findAllReferences === +// === /findAllRefsForDefaultExport03.ts === +// function [|f|]() { +// return 100; +// } +// +// /*FIND ALL REFS*/export default [|f|]; +// +// var x: typeof [|f|]; +// +// var y = [|f|](); +// +// namespace [|f|] { +// var local = 100; +// } + + + +// === findAllReferences === +// === /findAllRefsForDefaultExport03.ts === +// function [|f|]() { +// return 100; +// } +// +// export default /*FIND ALL REFS*/[|f|]; +// +// var x: typeof [|f|]; +// +// var y = [|f|](); +// +// namespace [|f|] { +// var local = 100; +// } + + + +// === findAllReferences === +// === /findAllRefsForDefaultExport03.ts === +// function [|f|]() { +// return 100; +// } +// +// export default [|f|]; +// +// var x: typeof /*FIND ALL REFS*/[|f|]; +// +// var y = [|f|](); +// +// namespace [|f|] { +// var local = 100; +// } + + + +// === findAllReferences === +// === /findAllRefsForDefaultExport03.ts === +// function [|f|]() { +// return 100; +// } +// +// export default [|f|]; +// +// var x: typeof [|f|]; +// +// var y = /*FIND ALL REFS*/[|f|](); +// +// namespace [|f|] { +// var local = 100; +// } + + + +// === findAllReferences === +// === /findAllRefsForDefaultExport03.ts === +// function [|f|]() { +// return 100; +// } +// +// export default [|f|]; +// +// var x: typeof [|f|]; +// +// var y = [|f|](); +// +// /*FIND ALL REFS*/namespace [|f|] { +// var local = 100; +// } + + + +// === findAllReferences === +// === /findAllRefsForDefaultExport03.ts === +// function [|f|]() { +// return 100; +// } +// +// export default [|f|]; +// +// var x: typeof [|f|]; +// +// var y = [|f|](); +// +// namespace /*FIND ALL REFS*/[|f|] { +// var local = 100; +// } \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForModule.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForModule.baseline.jsonc new file mode 100644 index 0000000000..9ffdfecb1a --- /dev/null +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForModule.baseline.jsonc @@ -0,0 +1,33 @@ +// === findAllReferences === +// === /b.ts === +// import { x } from "/*FIND ALL REFS*/[|./a|]"; + +// === /c/sub.js === +// const a = require("[|../a|]"); + +// === /d.ts === +// /// [||] + + + +// === findAllReferences === +// === /b.ts === +// import { x } from "[|./a|]"; + +// === /c/sub.js === +// const a = require("/*FIND ALL REFS*/[|../a|]"); + +// === /d.ts === +// /// [||] + + + +// === findAllReferences === +// === /b.ts === +// import { x } from "[|./a|]"; + +// === /c/sub.js === +// const a = require("[|../a|]"); + +// === /d.ts === +// /// [||] \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsModuleDotExports.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsModuleDotExports.baseline.jsonc new file mode 100644 index 0000000000..55f48ed43e --- /dev/null +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsModuleDotExports.baseline.jsonc @@ -0,0 +1,3 @@ +// === findAllReferences === +// === /a.js === +// /*FIND ALL REFS*/const [|b|] = require("./b"); \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/referencesForStatementKeywords.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/referencesForStatementKeywords.baseline.jsonc new file mode 100644 index 0000000000..ce52dab94e --- /dev/null +++ b/testdata/baselines/reference/fourslash/findAllReferences/referencesForStatementKeywords.baseline.jsonc @@ -0,0 +1,268 @@ +// === findAllReferences === +// === /main.ts === +// // import ... = ... +// /*FIND ALL REFS*/import [|A|] = require("./a"); +// namespace N { } +// import N2 = N; +// +// // --- (line: 6) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// // import ... = ... +// import A = /*FIND ALL REFS*/require("[|./a|]"); +// namespace N { } +// import N2 = N; +// +// // --- (line: 6) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// // import ... = ... +// import A = require("./a"); +// namespace N { } +// /*FIND ALL REFS*/import [|N2|] = N; +// +// // import ... from ... +// import type B from "./b"; +// // --- (line: 8) skipped --- + + + +// === findAllReferences === +// === /b.ts === +// export default class [|B|] {} + +// === /main.ts === +// --- (line: 3) skipped --- +// import N2 = N; +// +// // import ... from ... +// /*FIND ALL REFS*/import type [|B|] from "./b"; +// import type * as C from "./c"; +// import type { D } from "./d"; +// import type { e1, e2 as e3 } from "./e"; +// // --- (line: 11) skipped --- + + + +// === findAllReferences === +// === /b.ts === +// export default class [|B|] {} + +// === /main.ts === +// --- (line: 3) skipped --- +// import N2 = N; +// +// // import ... from ... +// import /*FIND ALL REFS*/type [|B|] from "./b"; +// import type * as C from "./c"; +// import type { D } from "./d"; +// import type { e1, e2 as e3 } from "./e"; +// // --- (line: 11) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 3) skipped --- +// import N2 = N; +// +// // import ... from ... +// import type B /*FIND ALL REFS*/from "[|./b|]"; +// import type * as C from "./c"; +// import type { D } from "./d"; +// import type { e1, e2 as e3 } from "./e"; +// // --- (line: 11) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 4) skipped --- +// +// // import ... from ... +// import type B from "./b"; +// /*FIND ALL REFS*/import type * as [|C|] from "./c"; +// import type { D } from "./d"; +// import type { e1, e2 as e3 } from "./e"; +// +// // --- (line: 12) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 4) skipped --- +// +// // import ... from ... +// import type B from "./b"; +// import /*FIND ALL REFS*/type * as [|C|] from "./c"; +// import type { D } from "./d"; +// import type { e1, e2 as e3 } from "./e"; +// +// // --- (line: 12) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 4) skipped --- +// +// // import ... from ... +// import type B from "./b"; +// import type * /*FIND ALL REFS*/as [|C|] from "./c"; +// import type { D } from "./d"; +// import type { e1, e2 as e3 } from "./e"; +// +// // --- (line: 12) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 4) skipped --- +// +// // import ... from ... +// import type B from "./b"; +// import type * as C /*FIND ALL REFS*/from "[|./c|]"; +// import type { D } from "./d"; +// import type { e1, e2 as e3 } from "./e"; +// +// // --- (line: 12) skipped --- + + + +// === findAllReferences === +// === /d.ts === +// export class [|D|] {} + +// === /main.ts === +// --- (line: 5) skipped --- +// // import ... from ... +// import type B from "./b"; +// import type * as C from "./c"; +// /*FIND ALL REFS*/import type { [|D|] } from "./d"; +// import type { e1, e2 as e3 } from "./e"; +// +// // import "module" +// // --- (line: 13) skipped --- + + + +// === findAllReferences === +// === /d.ts === +// export class [|D|] {} + +// === /main.ts === +// --- (line: 5) skipped --- +// // import ... from ... +// import type B from "./b"; +// import type * as C from "./c"; +// import /*FIND ALL REFS*/type { [|D|] } from "./d"; +// import type { e1, e2 as e3 } from "./e"; +// +// // import "module" +// // --- (line: 13) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 5) skipped --- +// // import ... from ... +// import type B from "./b"; +// import type * as C from "./c"; +// import type { D } /*FIND ALL REFS*/from "[|./d|]"; +// import type { e1, e2 as e3 } from "./e"; +// +// // import "module" +// // --- (line: 13) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 6) skipped --- +// import type B from "./b"; +// import type * as C from "./c"; +// import type { D } from "./d"; +// /*FIND ALL REFS*/import type { e1, e2 as e3 } from "./e"; +// +// // import "module" +// import "./f"; +// // --- (line: 14) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 6) skipped --- +// import type B from "./b"; +// import type * as C from "./c"; +// import type { D } from "./d"; +// import /*FIND ALL REFS*/type { e1, e2 as e3 } from "./e"; +// +// // import "module" +// import "./f"; +// // --- (line: 14) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 6) skipped --- +// import type B from "./b"; +// import type * as C from "./c"; +// import type { D } from "./d"; +// import type { e1, e2 as e3 } /*FIND ALL REFS*/from "[|./e|]"; +// +// // import "module" +// import "./f"; +// // --- (line: 14) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 6) skipped --- +// import type B from "./b"; +// import type * as C from "./c"; +// import type { D } from "./d"; +// import type { e1, e2 /*FIND ALL REFS*/as [|e3|] } from "./e"; +// +// // import "module" +// import "./f"; +// // --- (line: 14) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 9) skipped --- +// import type { e1, e2 as e3 } from "./e"; +// +// // import "module" +// /*FIND ALL REFS*/import "[|./f|]"; +// +// // export ... from ... +// export type * from "./g"; +// // --- (line: 17) skipped --- + + + +// === findAllReferences === +// === /main.ts === +// --- (line: 12) skipped --- +// import "./f"; +// +// // export ... from ... +// /*FIND ALL REFS*/export type * from "[|./g|]"; +// export type * as H from "./h"; +// export type { I } from "./i"; +// export type { j1, j2 as j3 } from "./j"; +// // --- (line: 20) skipped --- \ No newline at end of file From 6ffa90f47c58e96e2de577b78306069a36251b98 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Wed, 22 Oct 2025 09:31:24 -0700 Subject: [PATCH 2/5] bitten by the local baselines again --- .../findAllRefsForModule.baseline.jsonc | 9 - .../getOccurrencesIfElseBroken.baseline.jsonc | 57 ---- .../findAllRefsForModule.baseline.jsonc | 33 --- ...findAllRefsModuleDotExports.baseline.jsonc | 3 - ...erencesForStatementKeywords.baseline.jsonc | 268 ------------------ 5 files changed, 370 deletions(-) delete mode 100644 testdata/baselines/reference/fourslash/documentHighlights/findAllRefsForModule.baseline.jsonc delete mode 100644 testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesIfElseBroken.baseline.jsonc delete mode 100644 testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForModule.baseline.jsonc delete mode 100644 testdata/baselines/reference/fourslash/findAllReferences/findAllRefsModuleDotExports.baseline.jsonc delete mode 100644 testdata/baselines/reference/fourslash/findAllReferences/referencesForStatementKeywords.baseline.jsonc diff --git a/testdata/baselines/reference/fourslash/documentHighlights/findAllRefsForModule.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/findAllRefsForModule.baseline.jsonc deleted file mode 100644 index 35e8e3f07c..0000000000 --- a/testdata/baselines/reference/fourslash/documentHighlights/findAllRefsForModule.baseline.jsonc +++ /dev/null @@ -1,9 +0,0 @@ -// === documentHighlights === -// === /b.ts === -// import { x } from "/*HIGHLIGHTS*/[|./a|]"; - - - -// === documentHighlights === -// === /c/sub.js === -// const a = require("/*HIGHLIGHTS*/[|../a|]"); \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesIfElseBroken.baseline.jsonc b/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesIfElseBroken.baseline.jsonc deleted file mode 100644 index c1c381e16a..0000000000 --- a/testdata/baselines/reference/fourslash/documentHighlights/getOccurrencesIfElseBroken.baseline.jsonc +++ /dev/null @@ -1,57 +0,0 @@ -// === documentHighlights === -// === /getOccurrencesIfElseBroken.ts === -// /*HIGHLIGHTS*/[|if|] (true) { -// var x = 1; -// } -// [|else if|] () -// [|else if|] -// [|else|] /* whar garbl */ [|if|] (if (true) { } else { }) -// else - - - -// === documentHighlights === -// === /getOccurrencesIfElseBroken.ts === -// [|if|] (true) { -// var x = 1; -// } -// /*HIGHLIGHTS*/[|else if|] () -// [|else if|] -// [|else|] /* whar garbl */ [|if|] (if (true) { } else { }) -// else - - - -// === documentHighlights === -// === /getOccurrencesIfElseBroken.ts === -// [|if|] (true) { -// var x = 1; -// } -// [|else if|] () -// /*HIGHLIGHTS*/[|else if|] -// [|else|] /* whar garbl */ [|if|] (if (true) { } else { }) -// else - - - -// === documentHighlights === -// === /getOccurrencesIfElseBroken.ts === -// [|if|] (true) { -// var x = 1; -// } -// [|else if|] () -// [|else if|] -// /*HIGHLIGHTS*/[|else|] /* whar garbl */ [|if|] (if (true) { } else { }) -// else - - - -// === documentHighlights === -// === /getOccurrencesIfElseBroken.ts === -// [|if|] (true) { -// var x = 1; -// } -// [|else if|] () -// [|else if|] -// [|else|] /* whar garbl */ /*HIGHLIGHTS*/[|if|] (if (true) { } else { }) -// else \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForModule.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForModule.baseline.jsonc deleted file mode 100644 index 9ffdfecb1a..0000000000 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForModule.baseline.jsonc +++ /dev/null @@ -1,33 +0,0 @@ -// === findAllReferences === -// === /b.ts === -// import { x } from "/*FIND ALL REFS*/[|./a|]"; - -// === /c/sub.js === -// const a = require("[|../a|]"); - -// === /d.ts === -// /// [||] - - - -// === findAllReferences === -// === /b.ts === -// import { x } from "[|./a|]"; - -// === /c/sub.js === -// const a = require("/*FIND ALL REFS*/[|../a|]"); - -// === /d.ts === -// /// [||] - - - -// === findAllReferences === -// === /b.ts === -// import { x } from "[|./a|]"; - -// === /c/sub.js === -// const a = require("[|../a|]"); - -// === /d.ts === -// /// [||] \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsModuleDotExports.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsModuleDotExports.baseline.jsonc deleted file mode 100644 index 55f48ed43e..0000000000 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsModuleDotExports.baseline.jsonc +++ /dev/null @@ -1,3 +0,0 @@ -// === findAllReferences === -// === /a.js === -// /*FIND ALL REFS*/const [|b|] = require("./b"); \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/referencesForStatementKeywords.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/referencesForStatementKeywords.baseline.jsonc deleted file mode 100644 index ce52dab94e..0000000000 --- a/testdata/baselines/reference/fourslash/findAllReferences/referencesForStatementKeywords.baseline.jsonc +++ /dev/null @@ -1,268 +0,0 @@ -// === findAllReferences === -// === /main.ts === -// // import ... = ... -// /*FIND ALL REFS*/import [|A|] = require("./a"); -// namespace N { } -// import N2 = N; -// -// // --- (line: 6) skipped --- - - - -// === findAllReferences === -// === /main.ts === -// // import ... = ... -// import A = /*FIND ALL REFS*/require("[|./a|]"); -// namespace N { } -// import N2 = N; -// -// // --- (line: 6) skipped --- - - - -// === findAllReferences === -// === /main.ts === -// // import ... = ... -// import A = require("./a"); -// namespace N { } -// /*FIND ALL REFS*/import [|N2|] = N; -// -// // import ... from ... -// import type B from "./b"; -// // --- (line: 8) skipped --- - - - -// === findAllReferences === -// === /b.ts === -// export default class [|B|] {} - -// === /main.ts === -// --- (line: 3) skipped --- -// import N2 = N; -// -// // import ... from ... -// /*FIND ALL REFS*/import type [|B|] from "./b"; -// import type * as C from "./c"; -// import type { D } from "./d"; -// import type { e1, e2 as e3 } from "./e"; -// // --- (line: 11) skipped --- - - - -// === findAllReferences === -// === /b.ts === -// export default class [|B|] {} - -// === /main.ts === -// --- (line: 3) skipped --- -// import N2 = N; -// -// // import ... from ... -// import /*FIND ALL REFS*/type [|B|] from "./b"; -// import type * as C from "./c"; -// import type { D } from "./d"; -// import type { e1, e2 as e3 } from "./e"; -// // --- (line: 11) skipped --- - - - -// === findAllReferences === -// === /main.ts === -// --- (line: 3) skipped --- -// import N2 = N; -// -// // import ... from ... -// import type B /*FIND ALL REFS*/from "[|./b|]"; -// import type * as C from "./c"; -// import type { D } from "./d"; -// import type { e1, e2 as e3 } from "./e"; -// // --- (line: 11) skipped --- - - - -// === findAllReferences === -// === /main.ts === -// --- (line: 4) skipped --- -// -// // import ... from ... -// import type B from "./b"; -// /*FIND ALL REFS*/import type * as [|C|] from "./c"; -// import type { D } from "./d"; -// import type { e1, e2 as e3 } from "./e"; -// -// // --- (line: 12) skipped --- - - - -// === findAllReferences === -// === /main.ts === -// --- (line: 4) skipped --- -// -// // import ... from ... -// import type B from "./b"; -// import /*FIND ALL REFS*/type * as [|C|] from "./c"; -// import type { D } from "./d"; -// import type { e1, e2 as e3 } from "./e"; -// -// // --- (line: 12) skipped --- - - - -// === findAllReferences === -// === /main.ts === -// --- (line: 4) skipped --- -// -// // import ... from ... -// import type B from "./b"; -// import type * /*FIND ALL REFS*/as [|C|] from "./c"; -// import type { D } from "./d"; -// import type { e1, e2 as e3 } from "./e"; -// -// // --- (line: 12) skipped --- - - - -// === findAllReferences === -// === /main.ts === -// --- (line: 4) skipped --- -// -// // import ... from ... -// import type B from "./b"; -// import type * as C /*FIND ALL REFS*/from "[|./c|]"; -// import type { D } from "./d"; -// import type { e1, e2 as e3 } from "./e"; -// -// // --- (line: 12) skipped --- - - - -// === findAllReferences === -// === /d.ts === -// export class [|D|] {} - -// === /main.ts === -// --- (line: 5) skipped --- -// // import ... from ... -// import type B from "./b"; -// import type * as C from "./c"; -// /*FIND ALL REFS*/import type { [|D|] } from "./d"; -// import type { e1, e2 as e3 } from "./e"; -// -// // import "module" -// // --- (line: 13) skipped --- - - - -// === findAllReferences === -// === /d.ts === -// export class [|D|] {} - -// === /main.ts === -// --- (line: 5) skipped --- -// // import ... from ... -// import type B from "./b"; -// import type * as C from "./c"; -// import /*FIND ALL REFS*/type { [|D|] } from "./d"; -// import type { e1, e2 as e3 } from "./e"; -// -// // import "module" -// // --- (line: 13) skipped --- - - - -// === findAllReferences === -// === /main.ts === -// --- (line: 5) skipped --- -// // import ... from ... -// import type B from "./b"; -// import type * as C from "./c"; -// import type { D } /*FIND ALL REFS*/from "[|./d|]"; -// import type { e1, e2 as e3 } from "./e"; -// -// // import "module" -// // --- (line: 13) skipped --- - - - -// === findAllReferences === -// === /main.ts === -// --- (line: 6) skipped --- -// import type B from "./b"; -// import type * as C from "./c"; -// import type { D } from "./d"; -// /*FIND ALL REFS*/import type { e1, e2 as e3 } from "./e"; -// -// // import "module" -// import "./f"; -// // --- (line: 14) skipped --- - - - -// === findAllReferences === -// === /main.ts === -// --- (line: 6) skipped --- -// import type B from "./b"; -// import type * as C from "./c"; -// import type { D } from "./d"; -// import /*FIND ALL REFS*/type { e1, e2 as e3 } from "./e"; -// -// // import "module" -// import "./f"; -// // --- (line: 14) skipped --- - - - -// === findAllReferences === -// === /main.ts === -// --- (line: 6) skipped --- -// import type B from "./b"; -// import type * as C from "./c"; -// import type { D } from "./d"; -// import type { e1, e2 as e3 } /*FIND ALL REFS*/from "[|./e|]"; -// -// // import "module" -// import "./f"; -// // --- (line: 14) skipped --- - - - -// === findAllReferences === -// === /main.ts === -// --- (line: 6) skipped --- -// import type B from "./b"; -// import type * as C from "./c"; -// import type { D } from "./d"; -// import type { e1, e2 /*FIND ALL REFS*/as [|e3|] } from "./e"; -// -// // import "module" -// import "./f"; -// // --- (line: 14) skipped --- - - - -// === findAllReferences === -// === /main.ts === -// --- (line: 9) skipped --- -// import type { e1, e2 as e3 } from "./e"; -// -// // import "module" -// /*FIND ALL REFS*/import "[|./f|]"; -// -// // export ... from ... -// export type * from "./g"; -// // --- (line: 17) skipped --- - - - -// === findAllReferences === -// === /main.ts === -// --- (line: 12) skipped --- -// import "./f"; -// -// // export ... from ... -// /*FIND ALL REFS*/export type * from "[|./g|]"; -// export type * as H from "./h"; -// export type { I } from "./i"; -// export type { j1, j2 as j3 } from "./j"; -// // --- (line: 20) skipped --- \ No newline at end of file From 8103882a9f225c76856b74d51f597d2b0c3afe11 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Wed, 22 Oct 2025 09:49:17 -0700 Subject: [PATCH 3/5] Revert unrelated changes --- internal/fourslash/_scripts/failingTests.txt | 1 + .../fourslash/tests/gen/findAllRefsForDefaultExport03_test.go | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/fourslash/_scripts/failingTests.txt b/internal/fourslash/_scripts/failingTests.txt index 09435b6337..1db2b09ce7 100644 --- a/internal/fourslash/_scripts/failingTests.txt +++ b/internal/fourslash/_scripts/failingTests.txt @@ -167,6 +167,7 @@ TestDoubleUnderscoreCompletions TestEditJsdocType TestExportDefaultClass TestExportDefaultFunction +TestFindAllRefsForDefaultExport03 TestFindAllRefsForModule TestFindAllRefsModuleDotExports TestFindReferencesBindingPatternInJsdocNoCrash1 diff --git a/internal/fourslash/tests/gen/findAllRefsForDefaultExport03_test.go b/internal/fourslash/tests/gen/findAllRefsForDefaultExport03_test.go index 85578f9b73..f41ebfe43a 100644 --- a/internal/fourslash/tests/gen/findAllRefsForDefaultExport03_test.go +++ b/internal/fourslash/tests/gen/findAllRefsForDefaultExport03_test.go @@ -9,7 +9,7 @@ import ( func TestFindAllRefsForDefaultExport03(t *testing.T) { t.Parallel() - + t.Skip() defer testutil.RecoverAndFail(t, "Panic on fourslash test") const content = `/*1*/function /*2*/f() { return 100; From eb68a0b88463a49b74feaa8dba0e200100d6f6db Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Wed, 22 Oct 2025 09:49:35 -0700 Subject: [PATCH 4/5] Remove baseline --- ...ndAllRefsForDefaultExport03.baseline.jsonc | 141 ------------------ 1 file changed, 141 deletions(-) delete mode 100644 testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForDefaultExport03.baseline.jsonc diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForDefaultExport03.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForDefaultExport03.baseline.jsonc deleted file mode 100644 index 137945bf4a..0000000000 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForDefaultExport03.baseline.jsonc +++ /dev/null @@ -1,141 +0,0 @@ -// === findAllReferences === -// === /findAllRefsForDefaultExport03.ts === -// /*FIND ALL REFS*/function [|f|]() { -// return 100; -// } -// -// export default [|f|]; -// -// var x: typeof [|f|]; -// -// var y = [|f|](); -// -// namespace [|f|] { -// var local = 100; -// } - - - -// === findAllReferences === -// === /findAllRefsForDefaultExport03.ts === -// function /*FIND ALL REFS*/[|f|]() { -// return 100; -// } -// -// export default [|f|]; -// -// var x: typeof [|f|]; -// -// var y = [|f|](); -// -// namespace [|f|] { -// var local = 100; -// } - - - -// === findAllReferences === -// === /findAllRefsForDefaultExport03.ts === -// function [|f|]() { -// return 100; -// } -// -// /*FIND ALL REFS*/export default [|f|]; -// -// var x: typeof [|f|]; -// -// var y = [|f|](); -// -// namespace [|f|] { -// var local = 100; -// } - - - -// === findAllReferences === -// === /findAllRefsForDefaultExport03.ts === -// function [|f|]() { -// return 100; -// } -// -// export default /*FIND ALL REFS*/[|f|]; -// -// var x: typeof [|f|]; -// -// var y = [|f|](); -// -// namespace [|f|] { -// var local = 100; -// } - - - -// === findAllReferences === -// === /findAllRefsForDefaultExport03.ts === -// function [|f|]() { -// return 100; -// } -// -// export default [|f|]; -// -// var x: typeof /*FIND ALL REFS*/[|f|]; -// -// var y = [|f|](); -// -// namespace [|f|] { -// var local = 100; -// } - - - -// === findAllReferences === -// === /findAllRefsForDefaultExport03.ts === -// function [|f|]() { -// return 100; -// } -// -// export default [|f|]; -// -// var x: typeof [|f|]; -// -// var y = /*FIND ALL REFS*/[|f|](); -// -// namespace [|f|] { -// var local = 100; -// } - - - -// === findAllReferences === -// === /findAllRefsForDefaultExport03.ts === -// function [|f|]() { -// return 100; -// } -// -// export default [|f|]; -// -// var x: typeof [|f|]; -// -// var y = [|f|](); -// -// /*FIND ALL REFS*/namespace [|f|] { -// var local = 100; -// } - - - -// === findAllReferences === -// === /findAllRefsForDefaultExport03.ts === -// function [|f|]() { -// return 100; -// } -// -// export default [|f|]; -// -// var x: typeof [|f|]; -// -// var y = [|f|](); -// -// namespace /*FIND ALL REFS*/[|f|] { -// var local = 100; -// } \ No newline at end of file From b7605588b7c38f0372b4104aaa4144d0b5ab4110 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Wed, 22 Oct 2025 11:44:01 -0700 Subject: [PATCH 5/5] clamp position in PositionToLineAndCharacter maybe --- internal/ls/converters.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/internal/ls/converters.go b/internal/ls/converters.go index b7730f3e5d..2fb9d262a3 100644 --- a/internal/ls/converters.go +++ b/internal/ls/converters.go @@ -166,6 +166,8 @@ func (c *Converters) LineAndCharacterToPosition(script Script, lineAndCharacter func (c *Converters) PositionToLineAndCharacter(script Script, position core.TextPos) lsproto.Position { // UTF-8 offset to UTF-8/16 0-indexed line and character + position = min(position, core.TextPos(len(script.Text()))) + lineMap := c.getLineMap(script.FileName()) line, isLineStart := slices.BinarySearch(lineMap.LineStarts, position)