@singapore-editor/lsp-plugin 0.1.1 → 0.2.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +31 -77
  3. package/dist/codeActions.d.ts.map +1 -1
  4. package/dist/codeActions.js +1 -2
  5. package/dist/colorAlpha.js +1 -2
  6. package/dist/completion.js +3 -4
  7. package/dist/completion.js.map +1 -1
  8. package/dist/completionCommit.js +2 -3
  9. package/dist/completionCommit.js.map +1 -1
  10. package/dist/completionController.d.ts.map +1 -1
  11. package/dist/completionController.js +1 -2
  12. package/dist/completionProviders.d.ts.map +1 -1
  13. package/dist/completionProviders.js +2 -3
  14. package/dist/definitionLinkController.d.ts +4 -1
  15. package/dist/definitionLinkController.d.ts.map +1 -1
  16. package/dist/definitionLinkController.js +40 -20
  17. package/dist/definitionLinkController.js.map +1 -1
  18. package/dist/definitionNavigation.js +1 -2
  19. package/dist/diagnosticNotes.js +1 -2
  20. package/dist/diagnosticProjection.d.ts +1 -1
  21. package/dist/diagnosticProjection.d.ts.map +1 -1
  22. package/dist/diagnosticProjection.js +2 -3
  23. package/dist/diagnosticProjection.js.map +1 -1
  24. package/dist/diagnostics.js +1 -2
  25. package/dist/diagnosticsPresenter.d.ts.map +1 -1
  26. package/dist/diagnosticsPresenter.js +3 -4
  27. package/dist/diagnosticsPresenter.js.map +1 -1
  28. package/dist/document.d.ts +7 -6
  29. package/dist/document.d.ts.map +1 -1
  30. package/dist/document.js +36 -19
  31. package/dist/document.js.map +1 -1
  32. package/dist/documentHighlightController.d.ts.map +1 -1
  33. package/dist/documentHighlightController.js +1 -2
  34. package/dist/documentSnapshot.d.ts +3 -2
  35. package/dist/documentSnapshot.d.ts.map +1 -1
  36. package/dist/documentSnapshot.js +5 -6
  37. package/dist/documentSnapshot.js.map +1 -1
  38. package/dist/documentSync.d.ts +18 -20
  39. package/dist/documentSync.d.ts.map +1 -1
  40. package/dist/documentSync.js +120 -226
  41. package/dist/documentSync.js.map +1 -1
  42. package/dist/documentSyncController.d.ts +2 -4
  43. package/dist/documentSyncController.d.ts.map +1 -1
  44. package/dist/documentSyncController.js +2 -9
  45. package/dist/documentSyncController.js.map +1 -1
  46. package/dist/formatOnType.d.ts.map +1 -1
  47. package/dist/formatOnType.js +1 -2
  48. package/dist/formatting.js +1 -2
  49. package/dist/fuzzyMatch.js +1 -2
  50. package/dist/hoverParticipant.js +1 -2
  51. package/dist/index.d.ts +0 -1
  52. package/dist/index.d.ts.map +1 -1
  53. package/dist/index.js +2 -3
  54. package/dist/keyCommands.d.ts +10 -10
  55. package/dist/keyCommands.d.ts.map +1 -1
  56. package/dist/keyCommands.js +1 -2
  57. package/dist/lane.d.ts +1 -1
  58. package/dist/lane.d.ts.map +1 -1
  59. package/dist/lane.js +8 -6
  60. package/dist/lane.js.map +1 -1
  61. package/dist/lspConnection.d.ts.map +1 -1
  62. package/dist/lspConnection.js +1 -2
  63. package/dist/lspConnectionPool.d.ts.map +1 -1
  64. package/dist/lspConnectionPool.js +1 -2
  65. package/dist/minimalEdits.js +1 -2
  66. package/dist/paths.js +1 -2
  67. package/dist/plugin.d.ts +1 -1
  68. package/dist/plugin.d.ts.map +1 -1
  69. package/dist/plugin.js +25 -15
  70. package/dist/plugin.js.map +1 -1
  71. package/dist/plugin.styles.js +1 -2
  72. package/dist/pluginTypes.d.ts +5 -1
  73. package/dist/pluginTypes.d.ts.map +1 -1
  74. package/dist/pullDiagnostics.d.ts.map +1 -1
  75. package/dist/pullDiagnostics.js +1 -2
  76. package/dist/renameWidget.d.ts +2 -0
  77. package/dist/renameWidget.d.ts.map +1 -1
  78. package/dist/renameWidget.js +15 -14
  79. package/dist/renameWidget.js.map +1 -1
  80. package/dist/retainedSource.d.ts +41 -0
  81. package/dist/retainedSource.d.ts.map +1 -0
  82. package/dist/retainedSource.js +200 -0
  83. package/dist/retainedSource.js.map +1 -0
  84. package/dist/semanticTokenDecoder.js +1 -2
  85. package/dist/semanticTokens.d.ts.map +1 -1
  86. package/dist/semanticTokens.js +1 -2
  87. package/dist/serverSet.d.ts.map +1 -1
  88. package/dist/serverSet.js +27 -10
  89. package/dist/serverSet.js.map +1 -1
  90. package/dist/signatureHelp.js +1 -2
  91. package/dist/signatureHelpController.d.ts.map +1 -1
  92. package/dist/signatureHelpController.js +2 -2
  93. package/dist/signatureHelpController.js.map +1 -1
  94. package/dist/sourceConnection.d.ts +4 -0
  95. package/dist/sourceConnection.d.ts.map +1 -0
  96. package/dist/sourceConnection.js +21 -0
  97. package/dist/sourceConnection.js.map +1 -0
  98. package/dist/sourceText.js +1 -2
  99. package/dist/types.d.ts +2 -2
  100. package/dist/types.d.ts.map +1 -1
  101. package/dist/types.js +1 -2
  102. package/dist/types.js.map +1 -1
  103. package/dist/viewDocumentSnapshot.js +1 -2
  104. package/dist/workspaceEdit.js +1 -2
  105. package/dist/workspaceEditProvenance.d.ts.map +1 -1
  106. package/dist/workspaceEditProvenance.js +2 -3
  107. package/dist/workspaceEditProvenance.js.map +1 -1
  108. package/dist/workspaceTextEdits.d.ts +4 -1
  109. package/dist/workspaceTextEdits.d.ts.map +1 -1
  110. package/dist/workspaceTextEdits.js +21 -12
  111. package/dist/workspaceTextEdits.js.map +1 -1
  112. package/package.json +29 -11
  113. package/dist/bufferSync.d.ts +0 -12
  114. package/dist/bufferSync.d.ts.map +0 -1
  115. package/dist/bufferSync.js +0 -35
  116. package/dist/bufferSync.js.map +0 -1
package/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Shaul Lavo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
package/README.md CHANGED
@@ -1,103 +1,57 @@
1
1
  # @singapore-editor/lsp-plugin
2
2
 
3
- Editor integration layer for LSP-backed Singapore language features.
3
+ Language server diagnostics, completion, hover, and navigation for the Singapore editor.
4
4
 
5
- This package adapts `@singapore-editor/lsp` transports to `@singapore-editor/core` plugins for diagnostics,
6
- completion, hover, definition navigation, references, and document synchronization.
5
+ Part of [Singapore](https://singapore.shaulavo.dev/). A code editor for the browser that keeps every version.
7
6
 
8
7
  ## Install
9
8
 
10
9
  ```sh
11
- npm install @singapore-editor/core @singapore-editor/lsp @singapore-editor/lsp-plugin
10
+ npm install @singapore-editor/core @singapore-editor/lsp-plugin
12
11
  ```
13
12
 
14
13
  ## Usage
15
14
 
16
- ```ts
17
- import {
18
- createLanguageServerAdapterPlugin,
19
- createWebSocketLspTransportFactory,
20
- } from '@singapore-editor/lsp-plugin'
21
-
22
- const plugin = createLanguageServerAdapterPlugin({
23
- name: 'typescript-lsp',
24
- createTransport: createWebSocketLspTransportFactory('ws://localhost:3000/lsp'),
25
- documentSync: {
26
- shouldSyncLanguageId: (languageId) => languageId === 'typescript',
27
- },
28
- })
29
- ```
30
-
31
- ## Exports
32
-
33
- - `createLanguageServerAdapterPlugin` creates the full editor integration.
34
- - `createLanguageServerPlugin` exposes a lower-level plugin factory.
35
- - `createWebSocketLspTransportFactory` and `createWorkerLspTransportFactory` create transport
36
- factories.
37
- - Diagnostic, path, markdown tooltip, completion, and document-sync helpers are available through
38
- subpath exports.
39
-
40
- ## Keys
41
-
42
- The completion list and the signature hint are driven by editor commands, not by listening to
43
- keys: `editor.action.triggerSuggest` (Ctrl+Space), `selectNextSuggestion`, `selectPrevSuggestion`,
44
- `selectNextPageSuggestion`, `selectPrevPageSuggestion`, `acceptSelectedSuggestion`,
45
- `hideSuggestWidget`, `closeParameterHints`, `showNextParameterHint` and `showPrevParameterHint`.
46
- The core's `suggest` keymap pack binds them under the context keys this plugin registers
47
- (`suggestWidgetVisible`, `parameterHintsVisible`, `parameterHintsMultipleSignatures`). A host that
48
- turns the editor's keymap off, or drops that pack, binds these commands itself or the list cannot
49
- be driven from the keyboard. They are part of `commands`, so `commands: []` registers none of them.
50
-
51
- ## Document lifetime
52
-
53
- The connection-only API owns its document session automatically. Dispose the editor to close it:
15
+ Run a language server that accepts LSP JSON-RPC over WebSocket at the example URL.
54
16
 
55
17
  ```ts
56
- const plugin = createLanguageServerPlugin({
57
- webSocketRoute: 'ws://localhost:3001/lsp',
58
- })
59
- ```
18
+ import { Editor } from '@singapore-editor/core/editor'
19
+ import { createLanguageServerPlugin } from '@singapore-editor/lsp-plugin'
60
20
 
61
- For tabs or split editors, create a session beside the text buffer and pass it to each view:
21
+ const host = document.createElement('div')
22
+ host.style.height = '400px'
23
+ document.body.append(host)
62
24
 
63
- ```ts
64
- import {
65
- createLanguageServerDocument,
66
- createLanguageServerPlugin,
67
- } from '@singapore-editor/lsp-plugin'
68
-
69
- const document = createLanguageServerDocument({
70
- buffer,
71
- uri: 'file:///project/main.ts',
72
- languageId: 'typescript',
73
- lanes: [
74
- {
75
- id: 'typescript',
76
- features: { diagnostics: 0, completion: 0, hover: 0, navigation: 0 },
25
+ const editor = new Editor(host, {
26
+ plugins: [
27
+ createLanguageServerPlugin({
77
28
  webSocketRoute: 'ws://localhost:3001/lsp',
78
- },
29
+ rootUri: 'file:///project',
30
+ }),
79
31
  ],
80
32
  })
81
33
 
82
- const plugin = createLanguageServerPlugin({ document })
34
+ editor.openDocument({
35
+ documentId: '/project/main.ts',
36
+ text: 'const value: number = "one"\n',
37
+ languageId: 'typescript',
38
+ })
83
39
  ```
84
40
 
85
- The session synchronizes buffer changes and receives diagnostics even with no mounted view.
86
- Each view renders the current diagnostics on attachment. Disposing a view unsubscribes it;
87
- it does not close the document. The host calls `document.dispose()` when the document closes.
88
- Multiple views share the session, with independent completion, hover, and selection UI.
41
+ ## API highlights
42
+
43
+ - `createLanguageServerPlugin()` connects one server.
44
+ - `createLanguageServerSetPlugin()` assigns features to several servers.
45
+ - `onApplyWorkspaceEdit` sends cross-file edits to your app.
46
+
47
+ [Generated API reference](https://singapore.shaulavo.dev/docs/reference/api/lsp-plugin/overview/)
89
48
 
90
- Use `documentId` when the editor uses an opaque identity different from the URI. Connection
91
- options and an explicit `document` are mutually exclusive plugin inputs. Both forms use the
92
- same synchronization and diagnostic implementation.
49
+ ## In the Singapore family
93
50
 
94
- For shared sessions, pass `onApplyWorkspaceEdit` to `createLanguageServerDocument`.
95
- The document uses it both to advertise workspace-edit support during initialization and to
96
- apply edits requested by its views. It cannot be supplied on a plugin borrowing that document.
97
- The connection-only plugin still accepts `onApplyWorkspaceEdit` directly.
51
+ `@singapore-editor/core` owns the editor view. Add this plugin to connect the view to a language server.
98
52
 
99
- ### Diagnostic hover actions
53
+ [Singapore README](https://github.com/ShaulLavo/singapore/blob/main/README.md) · [Documentation](https://singapore.shaulavo.dev/docs/start-here/introduction/)
100
54
 
101
- `getDiagnosticActions({ documentUri, textVersion, diagnostic })` supplies actions beside each diagnostic note. It is supported by the server, server-set and adapter plugins, including `createTypeScriptLspPlugin`. Return an empty array when no action applies. Each action has a `label` and `run(): void | Promise<void>`.
55
+ ## License
102
56
 
103
- The tooltip prevents repeated invocation while an action is pending, preserves keyboard focus, and shows a rejected action's message beside its button. Progressive hover replies retain pending actions and their errors. An action refuses to run after its document, text version or diagnostic changes; the user can reopen the hover for a fresh action. The host owns application behavior and async operation state.
57
+ MIT. [License](https://github.com/ShaulLavo/singapore/blob/main/LICENSE)
@@ -1 +1 @@
1
- {"version":3,"file":"codeActions.d.ts","sourceRoot":"","sources":["../src/codeActions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,6BAA6B,EAC7B,gCAAgC,EACjC,MAAM,mCAAmC,CAAA;AAC1C,OAAO,EAGL,KAAK,uBAAuB,EAC7B,MAAM,uBAAuB,CAAA;AAC9B,OAAO,KAAK,KAAK,GAAG,MAAM,gCAAgC,CAAA;AAE1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0CAA0C,CAAA;AAC3E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAEnD,OAAO,EAEL,KAAK,8BAA8B,EACpC,MAAM,aAAa,CAAA;AAgBpB,MAAM,MAAM,kBAAkB,GAAG,SAAS,CAAC,GAAG,CAAC,OAAO,GAAG,GAAG,CAAC,UAAU,CAAC,EAAE,GAAG,IAAI,CAAA;AAEjF;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,kBAAkB,EAC5B,UAAU,EAAE,OAAO,GAClB,GAAG,CAAC,UAAU,GAAG,IAAI,CAevB;AAED;;;;;;;GAOG;AACH,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE,uBAAuB,EACjC,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,GACV,WAAW,GAAG,IAAI,CAYpB;AAED,MAAM,MAAM,2BAA2B,GAAG;IACxC,QAAQ,CAAC,MAAM,EAAE,8BAA8B,CAAA;IAC/C,QAAQ,CAAC,OAAO,EAAE,6BAA6B,CAAA;IAC/C,QAAQ,CAAC,iBAAiB,EAAE,MAAM,cAAc,GAAG,IAAI,CAAA;IACvD,QAAQ,CAAC,cAAc,EAAE,MAAM,SAAS,GAAG,CAAC,UAAU,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,OAAO,CAiB7B;IAEM,OAAO,IAAI,IAAI,CAKrB;IAED,OAAO,CAAC,QAAQ;IAahB,OAAO,CAAC,KAAK;YAWC,OAAO;YA8CP,SAAS;IA8BvB,OAAO,CAAC,eAAe;YAIT,cAAc;IA0C5B,OAAO,CAAC,oBAAoB;IAM5B,OAAO,CAAC,wBAAwB;IAMhC,OAAO,CAAC,iBAAiB;CAI1B"}
@@ -2,7 +2,7 @@ import { characterAt, rowBounds } from "./sourceText.js";
2
2
  import { parseWorkspaceEdit } from "./workspaceEdit.js";
3
3
  import { currentWorkspaceEditOrigin } from "./workspaceEditProvenance.js";
4
4
  import { lspPositionToOffsetInSnapshot, offsetToLspPositionInSnapshot } from "@singapore-editor/lsp";
5
- //#region src/codeActions.ts
5
+ // src/codeActions.ts
6
6
  /**
7
7
  * Long enough that a held arrow key or a burst of typing asks once, short enough that the answer is
8
8
  * already there when the hand leaves the keyboard and reaches for the fix.
@@ -288,7 +288,6 @@ function isAbortError(error) {
288
288
  function isRecord(value) {
289
289
  return typeof value === "object" && value !== null && !Array.isArray(value);
290
290
  }
291
- //#endregion
292
291
  export { CodeActionController, codeActionAutoTriggerRange, preferredQuickFix };
293
292
 
294
293
  //# sourceMappingURL=codeActions.js.map
@@ -1,4 +1,4 @@
1
- //#region src/colorAlpha.ts
1
+ // src/colorAlpha.ts
2
2
  /** Resolve registered CSS colors against the editor that supplies their theme variables. */
3
3
  function readColorAlpha(source, color) {
4
4
  const probe = source.ownerDocument.createElement("span");
@@ -22,7 +22,6 @@ function colorAlpha(color) {
22
22
  const alpha = Number.parseFloat(component) / (component.endsWith("%") ? 100 : 1);
23
23
  return Number.isFinite(alpha) ? Math.max(0, Math.min(1, alpha)) : 1;
24
24
  }
25
- //#endregion
26
25
  export { colorAlpha, readColorAlpha };
27
26
 
28
27
  //# sourceMappingURL=colorAlpha.js.map
@@ -1,9 +1,9 @@
1
1
  import { rangeAroundOffset, textReadSnapshotOf } from "./sourceText.js";
2
2
  import { fuzzyMatch, looseFuzzyMatch } from "./fuzzyMatch.js";
3
- import { lspPositionToOffsetInSnapshot } from "@singapore-editor/lsp";
4
3
  import { createEditorCapabilityToken, parseSnippet, snippetInitialSelection } from "@singapore-editor/core/extensions";
4
+ import { lspPositionToOffsetInSnapshot } from "@singapore-editor/lsp";
5
5
  import { createAnchoredSurface } from "@singapore-editor/plugin-ui/anchored-surface";
6
- //#region src/completion.ts
6
+ // src/completion.ts
7
7
  var LANGUAGE_SERVER_COMPLETION_EDIT_FEATURE_ID = "editor.lsp-plugin.completion-edit";
8
8
  var COMPLETION_REQUEST_DEBOUNCE_MS = 80;
9
9
  var LANGUAGE_SERVER_COMPLETION_EDIT_FEATURE = createEditorCapabilityToken(LANGUAGE_SERVER_COMPLETION_EDIT_FEATURE_ID);
@@ -151,7 +151,7 @@ function completionApplication(request, item) {
151
151
  const primary = completionPrimaryEdit(request, item);
152
152
  if (!primary) return null;
153
153
  const additional = additionalCompletionEdits(request, item.additionalTextEdits ?? []);
154
- const edits = [primary.edit, ...additional];
154
+ const edits = [primary.edit].concat(additional);
155
155
  const head = completionSelectionHead(primary.edit, additional);
156
156
  const snippet = primary.snippet;
157
157
  if (!snippet) return {
@@ -603,7 +603,6 @@ function compareCompletionOrder(left, right) {
603
603
  const rightKey = right.sortText ?? right.label;
604
604
  return leftKey.localeCompare(rightKey);
605
605
  }
606
- //#endregion
607
606
  export { COMPLETION_REQUEST_DEBOUNCE_MS, LANGUAGE_SERVER_COMPLETION_EDIT_FEATURE, LANGUAGE_SERVER_COMPLETION_EDIT_FEATURE_ID, completionAnchorRange, completionApplication, completionItemApplies, completionListResult, completionNeedsResolve, completionPrefix, completionTriggerFromChange, createCompletionEditFeature, createCompletionWidgetController, rankCompletionItems };
608
607
 
609
608
  //# sourceMappingURL=completion.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"completion.js","names":[],"sources":["../src/completion.ts"],"sourcesContent":["import type { SelectionAffinity, TextEdit } from '@singapore-editor/core/document'\nimport type {\n EditorContributionChange,\n EditorEditContributionContext,\n EditorSelectionRange,\n} from '@singapore-editor/core/extensions'\nimport { createEditorCapabilityToken } from '@singapore-editor/core/extensions'\nimport { lspPositionToOffsetInSnapshot, type LspTextDocumentSnapshot } from '@singapore-editor/lsp'\nimport type * as lsp from 'vscode-languageserver-protocol'\nimport {\n parseSnippet,\n snippetInitialSelection,\n type ParsedSnippet,\n type SnippetRange,\n} from '@singapore-editor/core/extensions'\n\nimport { createAnchoredSurface } from '@singapore-editor/plugin-ui/anchored-surface'\nimport { rangeAroundOffset, textReadSnapshotOf } from './sourceText'\nimport { fuzzyMatch, looseFuzzyMatch, type FuzzyMatch } from './fuzzyMatch'\n\nexport const LANGUAGE_SERVER_COMPLETION_EDIT_FEATURE_ID = 'editor.lsp-plugin.completion-edit'\n\nexport const COMPLETION_REQUEST_DEBOUNCE_MS = 80\n\nexport type LanguageServerCompletionEditFeature = {\n applyCompletion(application: LanguageServerCompletionApplication): boolean\n}\n\nexport const LANGUAGE_SERVER_COMPLETION_EDIT_FEATURE =\n createEditorCapabilityToken<LanguageServerCompletionEditFeature>(\n LANGUAGE_SERVER_COMPLETION_EDIT_FEATURE_ID,\n )\n\nexport type LanguageServerSnippetMirror = {\n readonly start: number\n readonly end: number\n /** Renders this copy from the stop's text; without one the copy holds that text verbatim. */\n readonly transform?: (value: string) => string\n}\n\nexport type LanguageServerSnippetStop = {\n readonly start: number\n readonly end: number\n readonly mirrors?: readonly LanguageServerSnippetMirror[]\n}\n\nexport type LanguageServerCompletionApplication = {\n readonly edits: readonly TextEdit[]\n readonly selection: EditorSelectionRange\n /**\n * Tab stops to cycle with Tab, each with the copies of it the snippet writes elsewhere, when the\n * accepted item was a snippet the host has something to track.\n */\n readonly snippetStops?: readonly LanguageServerSnippetStop[]\n}\n\n/** `3` is the kind reserved for asking a server again about a list it marked incomplete. */\nexport type LanguageServerCompletionTrigger = {\n readonly triggerKind: 1 | 2 | 3\n readonly triggerCharacter?: string\n}\n\nexport type CompletionWidgetShowOptions = {\n readonly anchor: DOMRect\n readonly items: readonly lsp.CompletionItem[]\n readonly selectedIndex?: number\n}\n\nexport type CompletionWidgetController = {\n show(options: CompletionWidgetShowOptions): void\n /** Moves a list already on screen to a new anchor, without rebuilding its rows. */\n reanchor(anchor: DOMRect): void\n hide(): void\n isVisible(): boolean\n containsTarget(target: EventTarget | null): boolean\n moveSelection(delta: number): void\n selectedItem(): lsp.CompletionItem | null\n dispose(): void\n}\n\nexport type CompletionWidgetOptions = {\n readonly document: Document\n readonly themeSource: HTMLElement\n readonly classNamespace?: string\n onSelect(index: number): void\n}\n\ntype CompletionWidgetClassNames = {\n readonly root: string\n readonly item: string\n readonly match: string\n}\n\nconst COMPLETION_WIDGET_GAP_PX = 4\nconst COMPLETION_WIDGET_WIDTH_PX = 320\nconst COMPLETION_WIDGET_MAX_HEIGHT_PX = 280\nconst COMPLETION_WIDGET_MARGIN_PX = 12\nconst COMPLETION_WIDGET_CLASS_NAMESPACE = 'lsp-plugin'\nconst COMPLETION_TRIGGER_CHARACTERS = new Set(['.', '\"', \"'\", '`', '/', '@', '<', '#'])\nconst COMPLETION_THEME_VARIABLES = [\n '--editor-background',\n '--editor-popup-background',\n '--editor-foreground',\n '--editor-caret-color',\n] as const\n\nexport function createCompletionWidgetController(\n options: CompletionWidgetOptions,\n): CompletionWidgetController {\n const classNames = completionWidgetClassNames(options.classNamespace)\n const element = createCompletionWidgetElement(options.document, classNames)\n options.document.body.append(element)\n const surface = createAnchoredSurface({\n element,\n anchorClassName: `${classNames.root}-anchor`,\n // Below the word, where the next thing typed continues it; above only when there is no room.\n preferredPlacement: 'bottom',\n alignment: 'start',\n gapPx: COMPLETION_WIDGET_GAP_PX,\n viewportMarginPx: COMPLETION_WIDGET_MARGIN_PX,\n maxHeightPx: COMPLETION_WIDGET_MAX_HEIGHT_PX,\n })\n\n let items: readonly lsp.CompletionItem[] = []\n let selectedIndex = 0\n let disposed = false\n\n const render = (): void => {\n element.replaceChildren()\n for (let index = 0; index < items.length; index += 1) {\n element.append(completionRowElement(element.ownerDocument, items[index]!, index, classNames))\n }\n syncSelectedRows(element, selectedIndex, classNames)\n }\n\n const show = (showOptions: CompletionWidgetShowOptions): void => {\n items = showOptions.items\n selectedIndex = clampIndex(showOptions.selectedIndex ?? 0, items.length)\n syncEditorThemeVariables(element, options.themeSource)\n render()\n element.hidden = items.length === 0\n // Placed once the rows are in and the list is visible: a hidden element measures as nothing,\n // and how tall it is decides whether it fits below the word.\n if (element.hidden) surface.release()\n else surface.place(showOptions.anchor)\n }\n\n const reanchor = (anchor: DOMRect): void => {\n if (element.hidden) return\n\n surface.place(anchor)\n }\n\n const hide = (): void => {\n element.hidden = true\n surface.release()\n element.replaceChildren()\n items = []\n selectedIndex = 0\n }\n\n const moveSelection = (delta: number): void => {\n if (items.length === 0) return\n\n selectedIndex = wrapIndex(selectedIndex + delta, items.length)\n syncSelectedRows(element, selectedIndex, classNames)\n }\n\n const selectedItem = (): lsp.CompletionItem | null => items[selectedIndex] ?? null\n\n const handlePointerDown = (event: PointerEvent): void => {\n const row = completionRowTarget(event.target, classNames)\n if (!row) return\n\n event.preventDefault()\n event.stopPropagation()\n selectedIndex = rowIndex(row)\n syncSelectedRows(element, selectedIndex, classNames)\n options.onSelect(selectedIndex)\n }\n\n element.addEventListener('pointerdown', handlePointerDown)\n\n const dispose = (): void => {\n if (disposed) return\n\n disposed = true\n element.removeEventListener('pointerdown', handlePointerDown)\n surface.dispose()\n element.remove()\n }\n\n return {\n show,\n reanchor,\n hide,\n isVisible: () => !element.hidden,\n containsTarget: (target) => target instanceof Node && element.contains(target),\n moveSelection,\n selectedItem,\n dispose,\n }\n}\n\n/**\n * A server's answer, with the one flag on it that outlives the request.\n *\n * `isIncomplete` is the server saying it truncated its answer for the word it was asked about — the\n * large member sets and auto-import lists are always sent this way — so a list that stays on screen\n * while the user keeps typing has to be asked again rather than narrowed.\n */\nexport type CompletionListResult = {\n readonly items: readonly lsp.CompletionItem[]\n readonly isIncomplete: boolean\n}\n\nexport function completionListResult(\n result: lsp.CompletionList | readonly lsp.CompletionItem[] | null,\n): CompletionListResult {\n if (!result) return { items: [], isIncomplete: false }\n if (isCompletionList(result))\n return { items: result.items ?? [], isIncomplete: result.isIncomplete === true }\n return { items: result, isIncomplete: false }\n}\n\nexport function completionTriggerFromChange(\n change: EditorContributionChange | null,\n): LanguageServerCompletionTrigger | null {\n if (!change || change.kind !== 'edit') return null\n if (change.edits.length !== 1) return null\n\n const edit = change.edits[0]\n if (!edit) return null\n\n const character = typedCharacter(edit)\n if (!character) return null\n if (COMPLETION_TRIGGER_CHARACTERS.has(character)) {\n return { triggerKind: 2, triggerCharacter: character }\n }\n if (isIdentifierCharacter(character)) return { triggerKind: 1 }\n return null\n}\n\n/**\n * The character the user typed, out of an edit that may have written more than it.\n *\n * A delimiter that closes itself arrives as the pair in a single insertion with the caret left\n * between the halves — which is exactly the keystroke a path or a member list is wanted for, so\n * reading only the one-character edits would leave the quote triggers unreachable while the editor\n * completes them. An insertion of one trigger character twice over is the whole of that shape;\n * anything else two characters wide is text arriving from somewhere other than the keyboard.\n */\nfunction typedCharacter(edit: TextEdit): string | null {\n if (edit.text.length === 1) return edit.text\n if (edit.from !== edit.to || edit.text.length !== 2) return null\n\n const opener = edit.text[0] ?? ''\n if (opener !== edit.text[1]) return null\n\n return COMPLETION_TRIGGER_CHARACTERS.has(opener) ? opener : null\n}\n\n/** The text a request went out with, which is the frame every range on an item is read in. */\nexport type CompletionApplicationDocument = {\n readonly document: LspTextDocumentSnapshot\n readonly offset: number\n}\n\n/**\n * The document an accepted item is applied against.\n *\n * `document` and `offset` are what the request went out with, and the item's ranges are positions\n * in that text. `caretOffset` and `caretAffinity` are where the caret has reached since — rarely the\n * same position, because the widget stays up while the user keeps typing.\n */\nexport type CompletionApplicationRequest = CompletionApplicationDocument & {\n readonly caretOffset: number\n readonly caretAffinity: SelectionAffinity\n}\n\nexport function completionApplication(\n request: CompletionApplicationRequest,\n item: lsp.CompletionItem,\n): LanguageServerCompletionApplication | null {\n const primary = completionPrimaryEdit(request, item)\n if (!primary) return null\n\n const additional = additionalCompletionEdits(request, item.additionalTextEdits ?? [])\n const edits = [primary.edit, ...additional]\n const head = completionSelectionHead(primary.edit, additional)\n const snippet = primary.snippet\n if (!snippet) {\n return { edits, selection: { anchor: head, head, affinity: request.caretAffinity } }\n }\n\n // A snippet's first placeholder is selected so the next keystroke replaces it; without a stop the\n // caret sits after the insertion exactly as a plain completion leaves it.\n const insertionOffset = head - primary.edit.text.length\n const first = snippetInitialSelection(snippet, insertionOffset)\n return {\n edits,\n selection: { anchor: first.start, head: first.end, affinity: request.caretAffinity },\n snippetStops: snippetStopRanges(snippet, insertionOffset),\n }\n}\n\n/**\n * Whether an item could be applied at all against the text it was answered for.\n *\n * The ranges an item carries are positions in that text, and one that spans lines or that the caret\n * was never inside describes a document this client did not ask about. Nothing downstream can rescue\n * such an item, so a row for it would be one the reader can press Enter on and get nothing for.\n */\nexport function completionItemApplies(\n request: CompletionApplicationDocument,\n item: lsp.CompletionItem,\n): boolean {\n const textEdit = completionTextEdit(item)\n if (!textEdit) return true\n\n return completionEditRange(request, textEdit.range) !== null\n}\n\nexport function completionAnchorRange(\n length: number,\n offset: number,\n): { readonly start: number; readonly end: number } {\n if (length === 0) return { start: 0, end: 0 }\n\n const end = Math.max(1, Math.min(offset, length))\n return { start: end - 1, end }\n}\n\nexport function createCompletionEditFeature(\n context: EditorEditContributionContext,\n timingName: string,\n): LanguageServerCompletionEditFeature {\n return {\n applyCompletion(application: LanguageServerCompletionApplication): boolean {\n if (!context.hasDocument()) return false\n\n context.applyEdits(application.edits, timingName, application.selection)\n // Started after the edit so the ranges refer to the text now in the document. A host without\n // the hook simply leaves the caret on the first placeholder.\n if (application.snippetStops) context.startSnippetSession(application.snippetStops)\n context.focusEditor()\n return true\n },\n }\n}\n\nfunction createCompletionWidgetElement(\n document: Document,\n classNames: CompletionWidgetClassNames,\n): HTMLDivElement {\n const element = document.createElement('div')\n element.className = classNames.root\n element.hidden = true\n element.setAttribute('role', 'listbox')\n Object.assign(element.style, {\n zIndex: '1001',\n width: `${COMPLETION_WIDGET_WIDTH_PX}px`,\n maxWidth: `calc(100vw - ${COMPLETION_WIDGET_MARGIN_PX * 2}px)`,\n maxHeight: `${COMPLETION_WIDGET_MAX_HEIGHT_PX}px`,\n overflowX: 'hidden',\n overflowY: 'auto',\n padding: '3px',\n border: '1px solid color-mix(in srgb, var(--editor-foreground, #d4d4d8) 22%, transparent)',\n borderRadius: '6px',\n boxSizing: 'border-box',\n background:\n 'var(--editor-popup-background, color-mix(in srgb, var(--editor-background, #18181b) 96%, var(--editor-foreground, #e4e4e7) 4%))',\n color: 'var(--editor-foreground, #e4e4e7)',\n boxShadow: '0 12px 30px color-mix(in srgb, var(--editor-background, #000000) 60%, transparent)',\n font: '12px/1.35 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace',\n userSelect: 'none',\n scrollbarGutter: 'stable',\n })\n return element\n}\n\nfunction completionRowElement(\n document: Document,\n item: lsp.CompletionItem,\n index: number,\n classNames: CompletionWidgetClassNames,\n): HTMLDivElement {\n const row = document.createElement('div')\n row.className = classNames.item\n row.dataset.index = String(index)\n row.setAttribute('role', 'option')\n Object.assign(row.style, {\n display: 'grid',\n gridTemplateColumns: '44px minmax(0, 1fr) auto',\n alignItems: 'center',\n gap: '8px',\n minHeight: '24px',\n padding: '2px 7px',\n borderRadius: '4px',\n cursor: 'default',\n whiteSpace: 'nowrap',\n })\n row.append(\n completionKindElement(document, item.kind),\n completionLabelElement(document, item, classNames),\n completionDetailElement(document, item),\n )\n return row\n}\n\nfunction completionKindElement(\n document: Document,\n kind: lsp.CompletionItemKind | undefined,\n): HTMLSpanElement {\n const element = document.createElement('span')\n element.textContent = completionKindLabel(kind)\n Object.assign(element.style, {\n minWidth: '0',\n overflow: 'hidden',\n color: 'color-mix(in srgb, var(--editor-foreground, #e4e4e7) 62%, transparent)',\n fontSize: '10px',\n textTransform: 'uppercase',\n })\n return element\n}\n\nfunction completionLabelElement(\n document: Document,\n item: lsp.CompletionItem,\n classNames: CompletionWidgetClassNames,\n): HTMLSpanElement {\n const element = document.createElement('span')\n Object.assign(element.style, {\n minWidth: '0',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n })\n appendCompletionLabel(element, item.label, completionLabelMatches.get(item) ?? [], classNames)\n const detail = item.labelDetails?.detail\n if (detail) element.append(detail)\n return element\n}\n\n/**\n * The label, with each run of characters the filter matched marked up.\n *\n * A list that reorders itself as the user types owes them the reason it did: with nothing marked, an\n * entry that outranks the one above it looks arbitrary rather than earned.\n */\nfunction appendCompletionLabel(\n element: HTMLElement,\n label: string,\n positions: readonly number[],\n classNames: CompletionWidgetClassNames,\n): void {\n let plainStart = 0\n let cursor = 0\n while (cursor < positions.length) {\n const start = positions[cursor] ?? 0\n let end = start + 1\n while (positions[cursor + 1] === end) {\n end += 1\n cursor += 1\n }\n cursor += 1\n\n if (start > plainStart) element.append(label.slice(plainStart, start))\n element.append(\n completionMatchElement(element.ownerDocument, label.slice(start, end), classNames),\n )\n plainStart = end\n }\n if (plainStart < label.length) element.append(label.slice(plainStart))\n}\n\nfunction completionMatchElement(\n document: Document,\n text: string,\n classNames: CompletionWidgetClassNames,\n): HTMLSpanElement {\n const element = document.createElement('span')\n element.className = classNames.match\n element.textContent = text\n Object.assign(element.style, {\n // The colour the caret is drawn in is the one the theme already means \"you are here\" by.\n color:\n 'color-mix(in srgb, var(--editor-caret-color, #60a5fa) 80%, var(--editor-foreground, #e4e4e7))',\n fontWeight: '600',\n })\n return element\n}\n\nfunction completionDetailElement(document: Document, item: lsp.CompletionItem): HTMLSpanElement {\n const element = document.createElement('span')\n element.textContent = item.labelDetails?.description ?? item.detail ?? ''\n Object.assign(element.style, {\n minWidth: '0',\n maxWidth: '140px',\n overflow: 'hidden',\n color: 'color-mix(in srgb, var(--editor-foreground, #e4e4e7) 58%, transparent)',\n textOverflow: 'ellipsis',\n })\n return element\n}\n\nfunction syncSelectedRows(\n element: HTMLDivElement,\n selectedIndex: number,\n classNames: CompletionWidgetClassNames,\n): void {\n const rows = element.querySelectorAll<HTMLElement>(`.${classNames.item}`)\n for (const row of rows) {\n const selected = rowIndex(row) === selectedIndex\n syncSelectedRow(row, selected)\n if (selected) scrollRowIntoView(element, row)\n }\n}\n\n/**\n * Keeps the focused row inside the box.\n *\n * A hundred rows are offered in a box a dozen of them fit in, and the widget never takes the focus,\n * so there is no scrollport the browser is moving on anyone's behalf: walking off the bottom edge —\n * or wrapping to the end with a single ArrowUp — would leave a list with no highlight in it while\n * Enter commits a row that was never on screen.\n */\nfunction scrollRowIntoView(element: HTMLElement, row: HTMLElement): void {\n const top = row.offsetTop\n const bottom = top + row.offsetHeight\n if (top < element.scrollTop) element.scrollTop = top\n else if (bottom > element.scrollTop + element.clientHeight) {\n element.scrollTop = bottom - element.clientHeight\n }\n}\n\nfunction syncSelectedRow(row: HTMLElement, selected: boolean): void {\n row.setAttribute('aria-selected', selected ? 'true' : 'false')\n row.style.background = selected\n ? 'color-mix(in srgb, var(--editor-caret-color, #60a5fa) 26%, transparent)'\n : 'transparent'\n}\n\nfunction syncEditorThemeVariables(element: HTMLElement, source: HTMLElement): void {\n const style = source.ownerDocument.defaultView?.getComputedStyle(source)\n if (!style) return\n\n for (const variable of COMPLETION_THEME_VARIABLES) {\n const value = style.getPropertyValue(variable)\n if (value) {\n element.style.setProperty(variable, value)\n continue\n }\n element.style.removeProperty(variable)\n }\n}\n\n/** The item's own insertion, and the snippet it was expanded from when the item carried one. */\ntype CompletionInsertion = {\n readonly edit: TextEdit\n readonly snippet: ParsedSnippet | null\n}\n\nfunction completionPrimaryEdit(\n request: CompletionApplicationRequest,\n item: lsp.CompletionItem,\n): CompletionInsertion | null {\n const textEdit = completionTextEdit(item)\n const range = textEdit\n ? completionEditRange(request, textEdit.range)\n : defaultCompletionReplacementRange(request.document, request.offset)\n if (!range) return null\n\n const source = textEdit ? textEdit.newText : (item.insertText ?? item.label)\n // Expanded against the document it is landing in, and once: the text that goes in and the offsets\n // the stops are reported at have to come from the same expansion or the caret lands off the\n // placeholder it is meant to select.\n const snippet =\n item.insertTextFormat === 2\n ? parseSnippet(source, {\n insertion: { textSnapshot: textReadSnapshotOf(request.document), offset: range.start },\n })\n : null\n\n return {\n snippet,\n edit: {\n from: range.start,\n // Whatever was typed since the request sits between the range's end and the caret, so the end\n // travels with the caret while the start — the word the server matched — stays where it is.\n to: Math.max(range.start, range.end + request.caretOffset - request.offset),\n text: snippet?.text ?? source,\n },\n }\n}\n\nfunction completionTextEdit(item: lsp.CompletionItem): lsp.TextEdit | null {\n const textEdit = item.textEdit\n if (!textEdit) return null\n if ('range' in textEdit) return textEdit\n // Of the two ranges an item may carry, `insert` stops at the caret while `replace` covers the\n // whole word it sits in. Insert would leave the tail of the word behind, which is neither what\n // the no-textEdit path below does nor what accepting mid-word is asking for.\n return { range: textEdit.replace, newText: textEdit.newText }\n}\n\n/**\n * The item's replacement range in offsets, or null when it describes a document we never asked\n * about: a range spanning lines, or one the caret was not inside, leaves nothing for the typed\n * characters to be measured against.\n */\nfunction completionEditRange(\n request: CompletionApplicationDocument,\n range: lsp.Range,\n): { readonly start: number; readonly end: number } | null {\n if (range.start.line !== range.end.line) return null\n\n const start = lspPositionToOffsetInSnapshot(request.document, range.start)\n const end = lspPositionToOffsetInSnapshot(request.document, range.end)\n if (start > request.offset || end < request.offset) return null\n\n return { start, end }\n}\n\nfunction additionalCompletionEdits(\n request: CompletionApplicationRequest,\n edits: readonly lsp.TextEdit[],\n): readonly TextEdit[] {\n return edits.map((edit) => {\n const from = lspPositionToOffsetInSnapshot(request.document, edit.range.start)\n const to = lspPositionToOffsetInSnapshot(request.document, edit.range.end)\n // An import edit above the caret is unmoved; one below it addresses text the typing has already\n // pushed along.\n const shift = from < request.offset ? 0 : request.caretOffset - request.offset\n return { from: from + shift, to: to + shift, text: edit.newText }\n })\n}\n\nfunction completionSelectionHead(primary: TextEdit, additional: readonly TextEdit[]): number {\n let head = primary.from + primary.text.length\n for (const edit of additional) {\n if (edit.to > primary.from) continue\n head += edit.text.length - (edit.to - edit.from)\n }\n return Math.max(0, head)\n}\n\nfunction defaultCompletionReplacementRange(\n document: LspTextDocumentSnapshot,\n offset: number,\n): { readonly start: number; readonly end: number } {\n const clamped = Math.max(0, Math.min(offset, document.textSnapshot.length))\n return rangeAroundOffset(document, clamped, identifierRunAt)\n}\n\nfunction identifierRunAt(text: string, offset: number): { start: number; end: number } {\n let start = offset\n while (start > 0 && isIdentifierCharacter(text[start - 1] ?? '')) start -= 1\n\n let end = offset\n while (end < text.length && isIdentifierCharacter(text[end] ?? '')) end += 1\n return { start, end }\n}\n\n/** Every tab stop in visit order and in document offsets, or undefined when there are none. */\nfunction snippetStopRanges(\n snippet: ParsedSnippet,\n insertionOffset: number,\n): readonly LanguageServerSnippetStop[] | undefined {\n const stops = snippet.stops.flatMap((stop) => {\n // The caret is offered the occurrence it can type into — never a transform's output, which is\n // rendered from another. Every further occurrence goes along as a copy, so a stop the snippet\n // writes twice reads the same in both places while the reader is still typing it.\n const caret = stop.ranges.findIndex((candidate) => !candidate.transform)\n const range = stop.ranges[caret]\n if (!range) return []\n\n const mirrors = stop.ranges.flatMap((mirror, index) =>\n index === caret ? [] : [shiftedSnippetRange(mirror, insertionOffset)],\n )\n const shifted = shiftedSnippetRange(range, insertionOffset)\n return [mirrors.length > 0 ? { ...shifted, mirrors } : shifted]\n })\n\n return stops.length > 0 ? stops : undefined\n}\n\nfunction shiftedSnippetRange(\n range: SnippetRange,\n insertionOffset: number,\n): LanguageServerSnippetMirror {\n const shifted = { end: insertionOffset + range.end, start: insertionOffset + range.start }\n return range.transform ? { ...shifted, transform: range.transform } : shifted\n}\n\nfunction completionRowTarget(\n target: EventTarget | null,\n classNames: CompletionWidgetClassNames,\n): HTMLElement | null {\n if (!(target instanceof Element)) return null\n return target.closest<HTMLElement>(`.${classNames.item}`)\n}\n\nfunction completionWidgetClassNames(\n namespace = COMPLETION_WIDGET_CLASS_NAMESPACE,\n): CompletionWidgetClassNames {\n const root = `editor-${namespace}-completion`\n return {\n root,\n item: `${root}-item`,\n match: `${root}-match`,\n }\n}\n\nfunction rowIndex(row: HTMLElement): number {\n const parsed = Number(row.dataset.index)\n return Number.isFinite(parsed) ? parsed : 0\n}\n\nfunction clampIndex(index: number, length: number): number {\n if (length <= 0) return 0\n return Math.min(Math.max(0, index), length - 1)\n}\n\nfunction wrapIndex(index: number, length: number): number {\n if (length <= 0) return 0\n return ((index % length) + length) % length\n}\n\nfunction completionKindLabel(kind: lsp.CompletionItemKind | undefined): string {\n if (kind === 2) return 'meth'\n if (kind === 3) return 'fn'\n if (kind === 5) return 'field'\n if (kind === 6) return 'var'\n if (kind === 7) return 'class'\n if (kind === 8) return 'iface'\n if (kind === 9) return 'mod'\n if (kind === 10) return 'prop'\n if (kind === 13) return 'enum'\n if (kind === 14) return 'key'\n if (kind === 20) return 'member'\n return 'text'\n}\n\nfunction isIdentifierCharacter(value: string): boolean {\n return /^[A-Za-z0-9_$]$/.test(value)\n}\n\nfunction isCompletionList(\n value: lsp.CompletionList | readonly lsp.CompletionItem[],\n): value is lsp.CompletionList {\n return !Array.isArray(value)\n}\n\n/**\n * Whether an accepted item still needs a `completionItem/resolve` round-trip.\n *\n * Servers routinely send a list whose items carry only a label, deferring documentation and — the\n * one that matters — the import edit until resolve. Applying such an item directly is what silently\n * drops auto-imports.\n */\nexport function completionNeedsResolve(\n item: lsp.CompletionItem,\n serverCapabilities: lsp.ServerCapabilities | null | undefined,\n): boolean {\n if (item.additionalTextEdits !== undefined) return false\n\n return Boolean(serverCapabilities?.completionProvider?.resolveProvider)\n}\n\n/**\n * Word being typed at `offset`, which is what the list should be filtered against. The server's\n * answer is for the moment the request was sent; the user has usually typed more since.\n */\nexport function completionPrefix(text: string, offset: number): string {\n let start = Math.max(0, Math.min(offset, text.length))\n while (start > 0 && isIdentifierCharacter(text[start - 1] ?? '')) start -= 1\n\n return text.slice(start, Math.max(0, Math.min(offset, text.length)))\n}\n\n/**\n * Where each ranked item's label matched, kept beside the list instead of inside it.\n *\n * The items in a list are the server's own objects, and one of them goes back to the server on a\n * resolve; the runs to mark are this client's reading of them. The widget is handed the items and\n * nothing else, so this is where it reads that from.\n */\nconst completionLabelMatches = new WeakMap<lsp.CompletionItem, readonly number[]>()\n\n/** What the last filter of a list produced, and the word it was produced from. */\ntype CompletionRanking = {\n readonly prefix: string\n readonly ranked: readonly lsp.CompletionItem[]\n}\n\n/**\n * Each server list's last filter, hung on the list itself.\n *\n * A narrowing is an answer about the one list it was computed from, and that list is held by a\n * single session in a single editor. Here it is out of reach of a second editor filtering its own\n * list, and it is released along with the session holding the list; in a variable of its own it\n * would be neither.\n */\nconst completionRankings = new WeakMap<readonly lsp.CompletionItem[], CompletionRanking>()\n\n/**\n * Filters and orders a completion list against what has been typed.\n *\n * An item earns its place by where the typed characters landed in it, so a word start, a camel-case\n * hump and the far side of a separator all outrank the same letters found in the middle of a word.\n * Ties fall back to the server's own `sortText`, which is how a server expresses relevance it knows\n * and the client does not.\n */\nexport function rankCompletionItems(\n items: readonly lsp.CompletionItem[],\n prefix: string,\n): readonly lsp.CompletionItem[] {\n if (prefix.length === 0) {\n completionRankings.delete(items)\n // The runs read a word that is no longer being typed, and the whole list is about to go back on\n // screen — including the items an earlier, longer word had already dropped.\n for (const item of items) completionLabelMatches.delete(item)\n return items\n }\n\n const scored: { item: lsp.CompletionItem; score: number }[] = []\n for (const item of narrowingSource(items, prefix)) {\n const match = fuzzyMatch(prefix, item.filterText ?? item.label)\n if (!match) continue\n\n completionLabelMatches.set(item, completionLabelPositions(item, prefix, match))\n scored.push({ item, score: match.score })\n }\n\n const ranked = scored\n .sort(\n (left, right) => right.score - left.score || compareCompletionOrder(left.item, right.item),\n )\n .map((entry) => entry.item)\n completionRankings.set(items, { prefix, ranked })\n return ranked\n}\n\n/**\n * The items worth scoring for this word: the ones that survived the shorter word, when this word is\n * that word plus what has been typed since.\n *\n * Typing a character can only narrow, never widen — no item the longer word matches was passed over\n * by the shorter one — so a server's list is scored in full once for the word it answered, and for\n * every keystroke the list stays up after that, only where it is still standing.\n */\nfunction narrowingSource(\n items: readonly lsp.CompletionItem[],\n prefix: string,\n): readonly lsp.CompletionItem[] {\n const previous = completionRankings.get(items)\n if (!previous) return items\n if (prefix.length <= previous.prefix.length || !prefix.startsWith(previous.prefix)) return items\n\n return previous.ranked\n}\n\n/**\n * The label positions to mark for an item, given the match its filter text earned.\n *\n * An item may be filtered by one string and displayed as another, and positions in the string that\n * was matched address nothing in the string on screen. Such a label is matched again on its own\n * terms, and loosely: part of what was typed has no reason to appear in it at all, and marking the\n * part that does beats marking nothing. The rank stays the one the filter text earned.\n */\nfunction completionLabelPositions(\n item: lsp.CompletionItem,\n prefix: string,\n match: FuzzyMatch,\n): readonly number[] {\n const filterText = item.filterText\n if (filterText === undefined) return match.positions\n if (filterText.toLowerCase() === item.label.toLowerCase()) return match.positions\n\n return looseFuzzyMatch(prefix, item.label)?.positions ?? []\n}\n\nfunction compareCompletionOrder(left: lsp.CompletionItem, right: lsp.CompletionItem): number {\n const leftKey = left.sortText ?? left.label\n const rightKey = right.sortText ?? right.label\n return leftKey.localeCompare(rightKey)\n}\n"],"mappings":";;;;;;AAoBA,IAAa,6CAA6C;AAE1D,IAAa,iCAAiC;AAM9C,IAAa,0CACX,4BACE,0CACF;AA8DF,IAAM,2BAA2B;AACjC,IAAM,6BAA6B;AACnC,IAAM,kCAAkC;AACxC,IAAM,8BAA8B;AACpC,IAAM,oCAAoC;AAC1C,IAAM,gDAAgC,IAAI,IAAI;CAAC;CAAK;CAAK;CAAK;CAAK;CAAK;CAAK;CAAK;AAAG,CAAC;AACtF,IAAM,6BAA6B;CACjC;CACA;CACA;CACA;AACF;AAEA,SAAgB,iCACd,SAC4B;CAC5B,MAAM,aAAa,2BAA2B,QAAQ,cAAc;CACpE,MAAM,UAAU,8BAA8B,QAAQ,UAAU,UAAU;CAC1E,QAAQ,SAAS,KAAK,OAAO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a,CAAC;AAC5D;AAEA,SAAS,uBAAuB,MAA0B,OAAmC;CAC3F,MAAM,UAAU,KAAK,YAAY,KAAK;CACtC,MAAM,WAAW,MAAM,YAAY,MAAM;CACzC,OAAO,QAAQ,cAAc,QAAQ;AACvC"}
1
+ {"version":3,"file":"completion.js","names":[],"sources":["../src/completion.ts"],"sourcesContent":["import type { SelectionAffinity, TextEdit } from '@singapore-editor/core/document'\nimport type {\n EditorContributionChange,\n EditorEditContributionContext,\n EditorSelectionRange,\n} from '@singapore-editor/core/extensions'\nimport { createEditorCapabilityToken } from '@singapore-editor/core/extensions'\nimport { lspPositionToOffsetInSnapshot, type LspTextDocumentSnapshot } from '@singapore-editor/lsp'\nimport type * as lsp from 'vscode-languageserver-protocol'\nimport {\n parseSnippet,\n snippetInitialSelection,\n type ParsedSnippet,\n type SnippetRange,\n} from '@singapore-editor/core/extensions'\n\nimport { createAnchoredSurface } from '@singapore-editor/plugin-ui/anchored-surface'\nimport { rangeAroundOffset, textReadSnapshotOf } from './sourceText'\nimport { fuzzyMatch, looseFuzzyMatch, type FuzzyMatch } from './fuzzyMatch'\n\nexport const LANGUAGE_SERVER_COMPLETION_EDIT_FEATURE_ID = 'editor.lsp-plugin.completion-edit'\n\nexport const COMPLETION_REQUEST_DEBOUNCE_MS = 80\n\nexport type LanguageServerCompletionEditFeature = {\n applyCompletion(application: LanguageServerCompletionApplication): boolean\n}\n\nexport const LANGUAGE_SERVER_COMPLETION_EDIT_FEATURE =\n createEditorCapabilityToken<LanguageServerCompletionEditFeature>(\n LANGUAGE_SERVER_COMPLETION_EDIT_FEATURE_ID,\n )\n\nexport type LanguageServerSnippetMirror = {\n readonly start: number\n readonly end: number\n /** Renders this copy from the stop's text; without one the copy holds that text verbatim. */\n readonly transform?: (value: string) => string\n}\n\nexport type LanguageServerSnippetStop = {\n readonly start: number\n readonly end: number\n readonly mirrors?: readonly LanguageServerSnippetMirror[]\n}\n\nexport type LanguageServerCompletionApplication = {\n readonly edits: readonly TextEdit[]\n readonly selection: EditorSelectionRange\n /**\n * Tab stops to cycle with Tab, each with the copies of it the snippet writes elsewhere, when the\n * accepted item was a snippet the host has something to track.\n */\n readonly snippetStops?: readonly LanguageServerSnippetStop[]\n}\n\n/** `3` is the kind reserved for asking a server again about a list it marked incomplete. */\nexport type LanguageServerCompletionTrigger = {\n readonly triggerKind: 1 | 2 | 3\n readonly triggerCharacter?: string\n}\n\nexport type CompletionWidgetShowOptions = {\n readonly anchor: DOMRect\n readonly items: readonly lsp.CompletionItem[]\n readonly selectedIndex?: number\n}\n\nexport type CompletionWidgetController = {\n show(options: CompletionWidgetShowOptions): void\n /** Moves a list already on screen to a new anchor, without rebuilding its rows. */\n reanchor(anchor: DOMRect): void\n hide(): void\n isVisible(): boolean\n containsTarget(target: EventTarget | null): boolean\n moveSelection(delta: number): void\n selectedItem(): lsp.CompletionItem | null\n dispose(): void\n}\n\nexport type CompletionWidgetOptions = {\n readonly document: Document\n readonly themeSource: HTMLElement\n readonly classNamespace?: string\n onSelect(index: number): void\n}\n\ntype CompletionWidgetClassNames = {\n readonly root: string\n readonly item: string\n readonly match: string\n}\n\nconst COMPLETION_WIDGET_GAP_PX = 4\nconst COMPLETION_WIDGET_WIDTH_PX = 320\nconst COMPLETION_WIDGET_MAX_HEIGHT_PX = 280\nconst COMPLETION_WIDGET_MARGIN_PX = 12\nconst COMPLETION_WIDGET_CLASS_NAMESPACE = 'lsp-plugin'\nconst COMPLETION_TRIGGER_CHARACTERS = new Set(['.', '\"', \"'\", '`', '/', '@', '<', '#'])\nconst COMPLETION_THEME_VARIABLES = [\n '--editor-background',\n '--editor-popup-background',\n '--editor-foreground',\n '--editor-caret-color',\n] as const\n\nexport function createCompletionWidgetController(\n options: CompletionWidgetOptions,\n): CompletionWidgetController {\n const classNames = completionWidgetClassNames(options.classNamespace)\n const element = createCompletionWidgetElement(options.document, classNames)\n options.document.body.append(element)\n const surface = createAnchoredSurface({\n element,\n anchorClassName: `${classNames.root}-anchor`,\n // Below the word, where the next thing typed continues it; above only when there is no room.\n preferredPlacement: 'bottom',\n alignment: 'start',\n gapPx: COMPLETION_WIDGET_GAP_PX,\n viewportMarginPx: COMPLETION_WIDGET_MARGIN_PX,\n maxHeightPx: COMPLETION_WIDGET_MAX_HEIGHT_PX,\n })\n\n let items: readonly lsp.CompletionItem[] = []\n let selectedIndex = 0\n let disposed = false\n\n const render = (): void => {\n element.replaceChildren()\n for (let index = 0; index < items.length; index += 1) {\n element.append(completionRowElement(element.ownerDocument, items[index]!, index, classNames))\n }\n syncSelectedRows(element, selectedIndex, classNames)\n }\n\n const show = (showOptions: CompletionWidgetShowOptions): void => {\n items = showOptions.items\n selectedIndex = clampIndex(showOptions.selectedIndex ?? 0, items.length)\n syncEditorThemeVariables(element, options.themeSource)\n render()\n element.hidden = items.length === 0\n // Placed once the rows are in and the list is visible: a hidden element measures as nothing,\n // and how tall it is decides whether it fits below the word.\n if (element.hidden) surface.release()\n else surface.place(showOptions.anchor)\n }\n\n const reanchor = (anchor: DOMRect): void => {\n if (element.hidden) return\n\n surface.place(anchor)\n }\n\n const hide = (): void => {\n element.hidden = true\n surface.release()\n element.replaceChildren()\n items = []\n selectedIndex = 0\n }\n\n const moveSelection = (delta: number): void => {\n if (items.length === 0) return\n\n selectedIndex = wrapIndex(selectedIndex + delta, items.length)\n syncSelectedRows(element, selectedIndex, classNames)\n }\n\n const selectedItem = (): lsp.CompletionItem | null => items[selectedIndex] ?? null\n\n const handlePointerDown = (event: PointerEvent): void => {\n const row = completionRowTarget(event.target, classNames)\n if (!row) return\n\n event.preventDefault()\n event.stopPropagation()\n selectedIndex = rowIndex(row)\n syncSelectedRows(element, selectedIndex, classNames)\n options.onSelect(selectedIndex)\n }\n\n element.addEventListener('pointerdown', handlePointerDown)\n\n const dispose = (): void => {\n if (disposed) return\n\n disposed = true\n element.removeEventListener('pointerdown', handlePointerDown)\n surface.dispose()\n element.remove()\n }\n\n return {\n show,\n reanchor,\n hide,\n isVisible: () => !element.hidden,\n containsTarget: (target) => target instanceof Node && element.contains(target),\n moveSelection,\n selectedItem,\n dispose,\n }\n}\n\n/**\n * A server's answer, with the one flag on it that outlives the request.\n *\n * `isIncomplete` is the server saying it truncated its answer for the word it was asked about — the\n * large member sets and auto-import lists are always sent this way — so a list that stays on screen\n * while the user keeps typing has to be asked again rather than narrowed.\n */\nexport type CompletionListResult = {\n readonly items: readonly lsp.CompletionItem[]\n readonly isIncomplete: boolean\n}\n\nexport function completionListResult(\n result: lsp.CompletionList | readonly lsp.CompletionItem[] | null,\n): CompletionListResult {\n if (!result) return { items: [], isIncomplete: false }\n if (isCompletionList(result))\n return { items: result.items ?? [], isIncomplete: result.isIncomplete === true }\n return { items: result, isIncomplete: false }\n}\n\nexport function completionTriggerFromChange(\n change: EditorContributionChange | null,\n): LanguageServerCompletionTrigger | null {\n if (!change || change.kind !== 'edit') return null\n if (change.edits.length !== 1) return null\n\n const edit = change.edits[0]\n if (!edit) return null\n\n const character = typedCharacter(edit)\n if (!character) return null\n if (COMPLETION_TRIGGER_CHARACTERS.has(character)) {\n return { triggerKind: 2, triggerCharacter: character }\n }\n if (isIdentifierCharacter(character)) return { triggerKind: 1 }\n return null\n}\n\n/**\n * The character the user typed, out of an edit that may have written more than it.\n *\n * A delimiter that closes itself arrives as the pair in a single insertion with the caret left\n * between the halves — which is exactly the keystroke a path or a member list is wanted for, so\n * reading only the one-character edits would leave the quote triggers unreachable while the editor\n * completes them. An insertion of one trigger character twice over is the whole of that shape;\n * anything else two characters wide is text arriving from somewhere other than the keyboard.\n */\nfunction typedCharacter(edit: TextEdit): string | null {\n if (edit.text.length === 1) return edit.text\n if (edit.from !== edit.to || edit.text.length !== 2) return null\n\n const opener = edit.text[0] ?? ''\n if (opener !== edit.text[1]) return null\n\n return COMPLETION_TRIGGER_CHARACTERS.has(opener) ? opener : null\n}\n\n/** The text a request went out with, which is the frame every range on an item is read in. */\nexport type CompletionApplicationDocument = {\n readonly document: LspTextDocumentSnapshot\n readonly offset: number\n}\n\n/**\n * The document an accepted item is applied against.\n *\n * `document` and `offset` are what the request went out with, and the item's ranges are positions\n * in that text. `caretOffset` and `caretAffinity` are where the caret has reached since — rarely the\n * same position, because the widget stays up while the user keeps typing.\n */\nexport type CompletionApplicationRequest = CompletionApplicationDocument & {\n readonly caretOffset: number\n readonly caretAffinity: SelectionAffinity\n}\n\nexport function completionApplication(\n request: CompletionApplicationRequest,\n item: lsp.CompletionItem,\n): LanguageServerCompletionApplication | null {\n const primary = completionPrimaryEdit(request, item)\n if (!primary) return null\n\n const additional = additionalCompletionEdits(request, item.additionalTextEdits ?? [])\n const edits = [primary.edit].concat(additional)\n const head = completionSelectionHead(primary.edit, additional)\n const snippet = primary.snippet\n if (!snippet) {\n return { edits, selection: { anchor: head, head, affinity: request.caretAffinity } }\n }\n\n // A snippet's first placeholder is selected so the next keystroke replaces it; without a stop the\n // caret sits after the insertion exactly as a plain completion leaves it.\n const insertionOffset = head - primary.edit.text.length\n const first = snippetInitialSelection(snippet, insertionOffset)\n return {\n edits,\n selection: { anchor: first.start, head: first.end, affinity: request.caretAffinity },\n snippetStops: snippetStopRanges(snippet, insertionOffset),\n }\n}\n\n/**\n * Whether an item could be applied at all against the text it was answered for.\n *\n * The ranges an item carries are positions in that text, and one that spans lines or that the caret\n * was never inside describes a document this client did not ask about. Nothing downstream can rescue\n * such an item, so a row for it would be one the reader can press Enter on and get nothing for.\n */\nexport function completionItemApplies(\n request: CompletionApplicationDocument,\n item: lsp.CompletionItem,\n): boolean {\n const textEdit = completionTextEdit(item)\n if (!textEdit) return true\n\n return completionEditRange(request, textEdit.range) !== null\n}\n\nexport function completionAnchorRange(\n length: number,\n offset: number,\n): { readonly start: number; readonly end: number } {\n if (length === 0) return { start: 0, end: 0 }\n\n const end = Math.max(1, Math.min(offset, length))\n return { start: end - 1, end }\n}\n\nexport function createCompletionEditFeature(\n context: EditorEditContributionContext,\n timingName: string,\n): LanguageServerCompletionEditFeature {\n return {\n applyCompletion(application: LanguageServerCompletionApplication): boolean {\n if (!context.hasDocument()) return false\n\n context.applyEdits(application.edits, timingName, application.selection)\n // Started after the edit so the ranges refer to the text now in the document. A host without\n // the hook simply leaves the caret on the first placeholder.\n if (application.snippetStops) context.startSnippetSession(application.snippetStops)\n context.focusEditor()\n return true\n },\n }\n}\n\nfunction createCompletionWidgetElement(\n document: Document,\n classNames: CompletionWidgetClassNames,\n): HTMLDivElement {\n const element = document.createElement('div')\n element.className = classNames.root\n element.hidden = true\n element.setAttribute('role', 'listbox')\n Object.assign(element.style, {\n zIndex: '1001',\n width: `${COMPLETION_WIDGET_WIDTH_PX}px`,\n maxWidth: `calc(100vw - ${COMPLETION_WIDGET_MARGIN_PX * 2}px)`,\n maxHeight: `${COMPLETION_WIDGET_MAX_HEIGHT_PX}px`,\n overflowX: 'hidden',\n overflowY: 'auto',\n padding: '3px',\n border: '1px solid color-mix(in srgb, var(--editor-foreground, #d4d4d8) 22%, transparent)',\n borderRadius: '6px',\n boxSizing: 'border-box',\n background:\n 'var(--editor-popup-background, color-mix(in srgb, var(--editor-background, #18181b) 96%, var(--editor-foreground, #e4e4e7) 4%))',\n color: 'var(--editor-foreground, #e4e4e7)',\n boxShadow: '0 12px 30px color-mix(in srgb, var(--editor-background, #000000) 60%, transparent)',\n font: '12px/1.35 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace',\n userSelect: 'none',\n scrollbarGutter: 'stable',\n })\n return element\n}\n\nfunction completionRowElement(\n document: Document,\n item: lsp.CompletionItem,\n index: number,\n classNames: CompletionWidgetClassNames,\n): HTMLDivElement {\n const row = document.createElement('div')\n row.className = classNames.item\n row.dataset.index = String(index)\n row.setAttribute('role', 'option')\n Object.assign(row.style, {\n display: 'grid',\n gridTemplateColumns: '44px minmax(0, 1fr) auto',\n alignItems: 'center',\n gap: '8px',\n minHeight: '24px',\n padding: '2px 7px',\n borderRadius: '4px',\n cursor: 'default',\n whiteSpace: 'nowrap',\n })\n row.append(\n completionKindElement(document, item.kind),\n completionLabelElement(document, item, classNames),\n completionDetailElement(document, item),\n )\n return row\n}\n\nfunction completionKindElement(\n document: Document,\n kind: lsp.CompletionItemKind | undefined,\n): HTMLSpanElement {\n const element = document.createElement('span')\n element.textContent = completionKindLabel(kind)\n Object.assign(element.style, {\n minWidth: '0',\n overflow: 'hidden',\n color: 'color-mix(in srgb, var(--editor-foreground, #e4e4e7) 62%, transparent)',\n fontSize: '10px',\n textTransform: 'uppercase',\n })\n return element\n}\n\nfunction completionLabelElement(\n document: Document,\n item: lsp.CompletionItem,\n classNames: CompletionWidgetClassNames,\n): HTMLSpanElement {\n const element = document.createElement('span')\n Object.assign(element.style, {\n minWidth: '0',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n })\n appendCompletionLabel(element, item.label, completionLabelMatches.get(item) ?? [], classNames)\n const detail = item.labelDetails?.detail\n if (detail) element.append(detail)\n return element\n}\n\n/**\n * The label, with each run of characters the filter matched marked up.\n *\n * A list that reorders itself as the user types owes them the reason it did: with nothing marked, an\n * entry that outranks the one above it looks arbitrary rather than earned.\n */\nfunction appendCompletionLabel(\n element: HTMLElement,\n label: string,\n positions: readonly number[],\n classNames: CompletionWidgetClassNames,\n): void {\n let plainStart = 0\n let cursor = 0\n while (cursor < positions.length) {\n const start = positions[cursor] ?? 0\n let end = start + 1\n while (positions[cursor + 1] === end) {\n end += 1\n cursor += 1\n }\n cursor += 1\n\n if (start > plainStart) element.append(label.slice(plainStart, start))\n element.append(\n completionMatchElement(element.ownerDocument, label.slice(start, end), classNames),\n )\n plainStart = end\n }\n if (plainStart < label.length) element.append(label.slice(plainStart))\n}\n\nfunction completionMatchElement(\n document: Document,\n text: string,\n classNames: CompletionWidgetClassNames,\n): HTMLSpanElement {\n const element = document.createElement('span')\n element.className = classNames.match\n element.textContent = text\n Object.assign(element.style, {\n // The colour the caret is drawn in is the one the theme already means \"you are here\" by.\n color:\n 'color-mix(in srgb, var(--editor-caret-color, #60a5fa) 80%, var(--editor-foreground, #e4e4e7))',\n fontWeight: '600',\n })\n return element\n}\n\nfunction completionDetailElement(document: Document, item: lsp.CompletionItem): HTMLSpanElement {\n const element = document.createElement('span')\n element.textContent = item.labelDetails?.description ?? item.detail ?? ''\n Object.assign(element.style, {\n minWidth: '0',\n maxWidth: '140px',\n overflow: 'hidden',\n color: 'color-mix(in srgb, var(--editor-foreground, #e4e4e7) 58%, transparent)',\n textOverflow: 'ellipsis',\n })\n return element\n}\n\nfunction syncSelectedRows(\n element: HTMLDivElement,\n selectedIndex: number,\n classNames: CompletionWidgetClassNames,\n): void {\n const rows = element.querySelectorAll<HTMLElement>(`.${classNames.item}`)\n for (const row of rows) {\n const selected = rowIndex(row) === selectedIndex\n syncSelectedRow(row, selected)\n if (selected) scrollRowIntoView(element, row)\n }\n}\n\n/**\n * Keeps the focused row inside the box.\n *\n * A hundred rows are offered in a box a dozen of them fit in, and the widget never takes the focus,\n * so there is no scrollport the browser is moving on anyone's behalf: walking off the bottom edge —\n * or wrapping to the end with a single ArrowUp — would leave a list with no highlight in it while\n * Enter commits a row that was never on screen.\n */\nfunction scrollRowIntoView(element: HTMLElement, row: HTMLElement): void {\n const top = row.offsetTop\n const bottom = top + row.offsetHeight\n if (top < element.scrollTop) element.scrollTop = top\n else if (bottom > element.scrollTop + element.clientHeight) {\n element.scrollTop = bottom - element.clientHeight\n }\n}\n\nfunction syncSelectedRow(row: HTMLElement, selected: boolean): void {\n row.setAttribute('aria-selected', selected ? 'true' : 'false')\n row.style.background = selected\n ? 'color-mix(in srgb, var(--editor-caret-color, #60a5fa) 26%, transparent)'\n : 'transparent'\n}\n\nfunction syncEditorThemeVariables(element: HTMLElement, source: HTMLElement): void {\n const style = source.ownerDocument.defaultView?.getComputedStyle(source)\n if (!style) return\n\n for (const variable of COMPLETION_THEME_VARIABLES) {\n const value = style.getPropertyValue(variable)\n if (value) {\n element.style.setProperty(variable, value)\n continue\n }\n element.style.removeProperty(variable)\n }\n}\n\n/** The item's own insertion, and the snippet it was expanded from when the item carried one. */\ntype CompletionInsertion = {\n readonly edit: TextEdit\n readonly snippet: ParsedSnippet | null\n}\n\nfunction completionPrimaryEdit(\n request: CompletionApplicationRequest,\n item: lsp.CompletionItem,\n): CompletionInsertion | null {\n const textEdit = completionTextEdit(item)\n const range = textEdit\n ? completionEditRange(request, textEdit.range)\n : defaultCompletionReplacementRange(request.document, request.offset)\n if (!range) return null\n\n const source = textEdit ? textEdit.newText : (item.insertText ?? item.label)\n // Expanded against the document it is landing in, and once: the text that goes in and the offsets\n // the stops are reported at have to come from the same expansion or the caret lands off the\n // placeholder it is meant to select.\n const snippet =\n item.insertTextFormat === 2\n ? parseSnippet(source, {\n insertion: { textSnapshot: textReadSnapshotOf(request.document), offset: range.start },\n })\n : null\n\n return {\n snippet,\n edit: {\n from: range.start,\n // Whatever was typed since the request sits between the range's end and the caret, so the end\n // travels with the caret while the start — the word the server matched — stays where it is.\n to: Math.max(range.start, range.end + request.caretOffset - request.offset),\n text: snippet?.text ?? source,\n },\n }\n}\n\nfunction completionTextEdit(item: lsp.CompletionItem): lsp.TextEdit | null {\n const textEdit = item.textEdit\n if (!textEdit) return null\n if ('range' in textEdit) return textEdit\n // Of the two ranges an item may carry, `insert` stops at the caret while `replace` covers the\n // whole word it sits in. Insert would leave the tail of the word behind, which is neither what\n // the no-textEdit path below does nor what accepting mid-word is asking for.\n return { range: textEdit.replace, newText: textEdit.newText }\n}\n\n/**\n * The item's replacement range in offsets, or null when it describes a document we never asked\n * about: a range spanning lines, or one the caret was not inside, leaves nothing for the typed\n * characters to be measured against.\n */\nfunction completionEditRange(\n request: CompletionApplicationDocument,\n range: lsp.Range,\n): { readonly start: number; readonly end: number } | null {\n if (range.start.line !== range.end.line) return null\n\n const start = lspPositionToOffsetInSnapshot(request.document, range.start)\n const end = lspPositionToOffsetInSnapshot(request.document, range.end)\n if (start > request.offset || end < request.offset) return null\n\n return { start, end }\n}\n\nfunction additionalCompletionEdits(\n request: CompletionApplicationRequest,\n edits: readonly lsp.TextEdit[],\n): readonly TextEdit[] {\n return edits.map((edit) => {\n const from = lspPositionToOffsetInSnapshot(request.document, edit.range.start)\n const to = lspPositionToOffsetInSnapshot(request.document, edit.range.end)\n // An import edit above the caret is unmoved; one below it addresses text the typing has already\n // pushed along.\n const shift = from < request.offset ? 0 : request.caretOffset - request.offset\n return { from: from + shift, to: to + shift, text: edit.newText }\n })\n}\n\nfunction completionSelectionHead(primary: TextEdit, additional: readonly TextEdit[]): number {\n let head = primary.from + primary.text.length\n for (const edit of additional) {\n if (edit.to > primary.from) continue\n head += edit.text.length - (edit.to - edit.from)\n }\n return Math.max(0, head)\n}\n\nfunction defaultCompletionReplacementRange(\n document: LspTextDocumentSnapshot,\n offset: number,\n): { readonly start: number; readonly end: number } {\n const clamped = Math.max(0, Math.min(offset, document.textSnapshot.length))\n return rangeAroundOffset(document, clamped, identifierRunAt)\n}\n\nfunction identifierRunAt(text: string, offset: number): { start: number; end: number } {\n let start = offset\n while (start > 0 && isIdentifierCharacter(text[start - 1] ?? '')) start -= 1\n\n let end = offset\n while (end < text.length && isIdentifierCharacter(text[end] ?? '')) end += 1\n return { start, end }\n}\n\n/** Every tab stop in visit order and in document offsets, or undefined when there are none. */\nfunction snippetStopRanges(\n snippet: ParsedSnippet,\n insertionOffset: number,\n): readonly LanguageServerSnippetStop[] | undefined {\n const stops = snippet.stops.flatMap((stop) => {\n // The caret is offered the occurrence it can type into — never a transform's output, which is\n // rendered from another. Every further occurrence goes along as a copy, so a stop the snippet\n // writes twice reads the same in both places while the reader is still typing it.\n const caret = stop.ranges.findIndex((candidate) => !candidate.transform)\n const range = stop.ranges[caret]\n if (!range) return []\n\n const mirrors = stop.ranges.flatMap((mirror, index) =>\n index === caret ? [] : [shiftedSnippetRange(mirror, insertionOffset)],\n )\n const shifted = shiftedSnippetRange(range, insertionOffset)\n return [mirrors.length > 0 ? { ...shifted, mirrors } : shifted]\n })\n\n return stops.length > 0 ? stops : undefined\n}\n\nfunction shiftedSnippetRange(\n range: SnippetRange,\n insertionOffset: number,\n): LanguageServerSnippetMirror {\n const shifted = { end: insertionOffset + range.end, start: insertionOffset + range.start }\n return range.transform ? { ...shifted, transform: range.transform } : shifted\n}\n\nfunction completionRowTarget(\n target: EventTarget | null,\n classNames: CompletionWidgetClassNames,\n): HTMLElement | null {\n if (!(target instanceof Element)) return null\n return target.closest<HTMLElement>(`.${classNames.item}`)\n}\n\nfunction completionWidgetClassNames(\n namespace = COMPLETION_WIDGET_CLASS_NAMESPACE,\n): CompletionWidgetClassNames {\n const root = `editor-${namespace}-completion`\n return {\n root,\n item: `${root}-item`,\n match: `${root}-match`,\n }\n}\n\nfunction rowIndex(row: HTMLElement): number {\n const parsed = Number(row.dataset.index)\n return Number.isFinite(parsed) ? parsed : 0\n}\n\nfunction clampIndex(index: number, length: number): number {\n if (length <= 0) return 0\n return Math.min(Math.max(0, index), length - 1)\n}\n\nfunction wrapIndex(index: number, length: number): number {\n if (length <= 0) return 0\n return ((index % length) + length) % length\n}\n\nfunction completionKindLabel(kind: lsp.CompletionItemKind | undefined): string {\n if (kind === 2) return 'meth'\n if (kind === 3) return 'fn'\n if (kind === 5) return 'field'\n if (kind === 6) return 'var'\n if (kind === 7) return 'class'\n if (kind === 8) return 'iface'\n if (kind === 9) return 'mod'\n if (kind === 10) return 'prop'\n if (kind === 13) return 'enum'\n if (kind === 14) return 'key'\n if (kind === 20) return 'member'\n return 'text'\n}\n\nfunction isIdentifierCharacter(value: string): boolean {\n return /^[A-Za-z0-9_$]$/.test(value)\n}\n\nfunction isCompletionList(\n value: lsp.CompletionList | readonly lsp.CompletionItem[],\n): value is lsp.CompletionList {\n return !Array.isArray(value)\n}\n\n/**\n * Whether an accepted item still needs a `completionItem/resolve` round-trip.\n *\n * Servers routinely send a list whose items carry only a label, deferring documentation and — the\n * one that matters — the import edit until resolve. Applying such an item directly is what silently\n * drops auto-imports.\n */\nexport function completionNeedsResolve(\n item: lsp.CompletionItem,\n serverCapabilities: lsp.ServerCapabilities | null | undefined,\n): boolean {\n if (item.additionalTextEdits !== undefined) return false\n\n return Boolean(serverCapabilities?.completionProvider?.resolveProvider)\n}\n\n/**\n * Word being typed at `offset`, which is what the list should be filtered against. The server's\n * answer is for the moment the request was sent; the user has usually typed more since.\n */\nexport function completionPrefix(text: string, offset: number): string {\n let start = Math.max(0, Math.min(offset, text.length))\n while (start > 0 && isIdentifierCharacter(text[start - 1] ?? '')) start -= 1\n\n return text.slice(start, Math.max(0, Math.min(offset, text.length)))\n}\n\n/**\n * Where each ranked item's label matched, kept beside the list instead of inside it.\n *\n * The items in a list are the server's own objects, and one of them goes back to the server on a\n * resolve; the runs to mark are this client's reading of them. The widget is handed the items and\n * nothing else, so this is where it reads that from.\n */\nconst completionLabelMatches = new WeakMap<lsp.CompletionItem, readonly number[]>()\n\n/** What the last filter of a list produced, and the word it was produced from. */\ntype CompletionRanking = {\n readonly prefix: string\n readonly ranked: readonly lsp.CompletionItem[]\n}\n\n/**\n * Each server list's last filter, hung on the list itself.\n *\n * A narrowing is an answer about the one list it was computed from, and that list is held by a\n * single session in a single editor. Here it is out of reach of a second editor filtering its own\n * list, and it is released along with the session holding the list; in a variable of its own it\n * would be neither.\n */\nconst completionRankings = new WeakMap<readonly lsp.CompletionItem[], CompletionRanking>()\n\n/**\n * Filters and orders a completion list against what has been typed.\n *\n * An item earns its place by where the typed characters landed in it, so a word start, a camel-case\n * hump and the far side of a separator all outrank the same letters found in the middle of a word.\n * Ties fall back to the server's own `sortText`, which is how a server expresses relevance it knows\n * and the client does not.\n */\nexport function rankCompletionItems(\n items: readonly lsp.CompletionItem[],\n prefix: string,\n): readonly lsp.CompletionItem[] {\n if (prefix.length === 0) {\n completionRankings.delete(items)\n // The runs read a word that is no longer being typed, and the whole list is about to go back on\n // screen — including the items an earlier, longer word had already dropped.\n for (const item of items) completionLabelMatches.delete(item)\n return items\n }\n\n const scored: { item: lsp.CompletionItem; score: number }[] = []\n for (const item of narrowingSource(items, prefix)) {\n const match = fuzzyMatch(prefix, item.filterText ?? item.label)\n if (!match) continue\n\n completionLabelMatches.set(item, completionLabelPositions(item, prefix, match))\n scored.push({ item, score: match.score })\n }\n\n const ranked = scored\n .sort(\n (left, right) => right.score - left.score || compareCompletionOrder(left.item, right.item),\n )\n .map((entry) => entry.item)\n completionRankings.set(items, { prefix, ranked })\n return ranked\n}\n\n/**\n * The items worth scoring for this word: the ones that survived the shorter word, when this word is\n * that word plus what has been typed since.\n *\n * Typing a character can only narrow, never widen — no item the longer word matches was passed over\n * by the shorter one — so a server's list is scored in full once for the word it answered, and for\n * every keystroke the list stays up after that, only where it is still standing.\n */\nfunction narrowingSource(\n items: readonly lsp.CompletionItem[],\n prefix: string,\n): readonly lsp.CompletionItem[] {\n const previous = completionRankings.get(items)\n if (!previous) return items\n if (prefix.length <= previous.prefix.length || !prefix.startsWith(previous.prefix)) return items\n\n return previous.ranked\n}\n\n/**\n * The label positions to mark for an item, given the match its filter text earned.\n *\n * An item may be filtered by one string and displayed as another, and positions in the string that\n * was matched address nothing in the string on screen. Such a label is matched again on its own\n * terms, and loosely: part of what was typed has no reason to appear in it at all, and marking the\n * part that does beats marking nothing. The rank stays the one the filter text earned.\n */\nfunction completionLabelPositions(\n item: lsp.CompletionItem,\n prefix: string,\n match: FuzzyMatch,\n): readonly number[] {\n const filterText = item.filterText\n if (filterText === undefined) return match.positions\n if (filterText.toLowerCase() === item.label.toLowerCase()) return match.positions\n\n return looseFuzzyMatch(prefix, item.label)?.positions ?? []\n}\n\nfunction compareCompletionOrder(left: lsp.CompletionItem, right: lsp.CompletionItem): number {\n const leftKey = left.sortText ?? left.label\n const rightKey = right.sortText ?? right.label\n return leftKey.localeCompare(rightKey)\n}\n"],"mappings":";;;;;;AAoBA,IAAa,6CAA6C;AAE1D,IAAa,iCAAiC;AAM9C,IAAa,0CACX,4BACE,0CACF;AA8DF,IAAM,2BAA2B;AACjC,IAAM,6BAA6B;AACnC,IAAM,kCAAkC;AACxC,IAAM,8BAA8B;AACpC,IAAM,oCAAoC;AAC1C,IAAM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W,SAAS,MAAM,GAAG,OAAO;CAE3F,OAAO,SAAS;AAClB;;;;;;;;;AAUA,SAAS,yBACP,MACA,QACA,OACmB;CACnB,MAAM,aAAa,KAAK;CACxB,IAAI,eAAe,KAAA,GAAW,OAAO,MAAM;CAC3C,IAAI,WAAW,YAAY,MAAM,KAAK,MAAM,YAAY,GAAG,OAAO,MAAM;CAExE,OAAO,gBAAgB,QAAQ,KAAK,KAAK,CAAC,EAAE,aAAa,CAAC;AAC5D;AAEA,SAAS,uBAAuB,MAA0B,OAAmC;CAC3F,MAAM,UAAU,KAAK,YAAY,KAAK;CACtC,MAAM,WAAW,MAAM,YAAY,MAAM;CACzC,OAAO,QAAQ,cAAc,QAAQ;AACvC"}
@@ -1,4 +1,4 @@
1
- //#region src/completionCommit.ts
1
+ // src/completionCommit.ts
2
2
  /**
3
3
  * The character just typed, when the focused item asks to be accepted on it.
4
4
  *
@@ -36,7 +36,7 @@ function completionCommitApplication(application, character) {
36
36
  const edits = [{
37
37
  ...insertion,
38
38
  text: `${insertion.text}${character}`
39
- }, ...additional];
39
+ }].concat(additional);
40
40
  if (application.snippetStops) return {
41
41
  ...application,
42
42
  edits
@@ -51,7 +51,6 @@ function completionCommitApplication(application, character) {
51
51
  }
52
52
  };
53
53
  }
54
- //#endregion
55
54
  export { completionCommitCharacter, completionCommitFeature };
56
55
 
57
56
  //# sourceMappingURL=completionCommit.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"completionCommit.js","names":[],"sources":["../src/completionCommit.ts"],"sourcesContent":["import type * as lsp from 'vscode-languageserver-protocol'\n\nimport type {\n LanguageServerCompletionApplication,\n LanguageServerCompletionEditFeature,\n} from './completion'\n\n/**\n * The character just typed, when the focused item asks to be accepted on it.\n *\n * Read off the focused item at the keystroke rather than kept in a set beside it: an item declares\n * two or three of these, so there is nothing to amortize, and a set that outlives the focus it was\n * built from is a set that accepts an item the user is no longer looking at.\n */\nexport function completionCommitCharacter(\n event: KeyboardEvent,\n item: lsp.CompletionItem | null,\n enabled: boolean,\n): string | null {\n if (!enabled || !item) return null\n // A modifier makes the keystroke a command — `Ctrl+.` is a binding, not a typed period — and `key`\n // only names the character typed when it names a single character at all.\n if (event.ctrlKey || event.metaKey || event.altKey) return null\n if (event.key.length !== 1) return null\n\n return item.commitCharacters?.includes(event.key) === true ? event.key : null\n}\n\n/**\n * The edit feature with `character` folded into whatever acceptance goes through it.\n *\n * One acceptance is one call and so one undo entry, which is the whole reason the character travels\n * inside it: inserted afterwards it would be an entry of its own, and undoing the completion would\n * leave it stranded on the word it was meant to follow.\n */\nexport function completionCommitFeature(\n feature: LanguageServerCompletionEditFeature,\n character: string | null,\n): LanguageServerCompletionEditFeature {\n if (character === null) return feature\n\n return {\n applyCompletion: (application) =>\n feature.applyCompletion(completionCommitApplication(application, character)),\n }\n}\n\n/**\n * The acceptance with the commit character appended to what the item inserts.\n *\n * The character is why the item was accepted, so it has to end up after the insertion exactly as it\n * was typed — `arr.fil` committed on `(` reads `arr.filter(`, and dropping the character is the one\n * outcome that makes the interaction worse than not having it.\n */\nfunction completionCommitApplication(\n application: LanguageServerCompletionApplication,\n character: string,\n): LanguageServerCompletionApplication {\n const [insertion, ...additional] = application.edits\n if (!insertion) return application\n\n const edits = [{ ...insertion, text: `${insertion.text}${character}` }, ...additional]\n // A snippet's caret belongs on its first placeholder, and the character lands past the end of the\n // insertion, so every stop measured inside it is still where it was.\n if (application.snippetStops) return { ...application, edits }\n\n const head = application.selection.head + character.length\n return { edits, selection: { ...application.selection, anchor: head, head } }\n}\n"],"mappings":";;;;;;;;AAcA,SAAgB,0BACd,OACA,MACA,SACe;CACf,IAAI,CAAC,WAAW,CAAC,MAAM,OAAO;CAG9B,IAAI,MAAM,WAAW,MAAM,WAAW,MAAM,QAAQ,OAAO;CAC3D,IAAI,MAAM,IAAI,WAAW,GAAG,OAAO;CAEnC,OAAO,KAAK,kBAAkB,SAAS,MAAM,GAAG,MAAM,OAAO,MAAM,MAAM;AAC3E;;;;;;;;AASA,SAAgB,wBACd,SACA,WACqC;CACrC,IAAI,cAAc,MAAM,OAAO;CAE/B,OAAO,EACL,kBAAkB,gBAChB,QAAQ,gBAAgB,4BAA4B,aAAa,SAAS,CAAC,EAC/E;AACF;;;;;;;;AASA,SAAS,4BACP,aACA,WACqC;CACrC,MAAM,CAAC,WAAW,GAAG,cAAc,YAAY;CAC/C,IAAI,CAAC,WAAW,OAAO;CAEvB,MAAM,QAAQ,CAAC;EAAE,GAAG;EAAW,MAAM,GAAG,UAAU,OAAO;CAAY,GAAG,GAAG,UAAU;CAGrF,IAAI,YAAY,cAAc,OAAO;EAAE,GAAG;EAAa;CAAM;CAE7D,MAAM,OAAO,YAAY,UAAU,OAAO,UAAU;CACpD,OAAO;EAAE;EAAO,WAAW;GAAE,GAAG,YAAY;GAAW,QAAQ;GAAM;EAAK;CAAE;AAC9E"}
1
+ {"version":3,"file":"completionCommit.js","names":[],"sources":["../src/completionCommit.ts"],"sourcesContent":["import type * as lsp from 'vscode-languageserver-protocol'\n\nimport type {\n LanguageServerCompletionApplication,\n LanguageServerCompletionEditFeature,\n} from './completion'\n\n/**\n * The character just typed, when the focused item asks to be accepted on it.\n *\n * Read off the focused item at the keystroke rather than kept in a set beside it: an item declares\n * two or three of these, so there is nothing to amortize, and a set that outlives the focus it was\n * built from is a set that accepts an item the user is no longer looking at.\n */\nexport function completionCommitCharacter(\n event: KeyboardEvent,\n item: lsp.CompletionItem | null,\n enabled: boolean,\n): string | null {\n if (!enabled || !item) return null\n // A modifier makes the keystroke a command — `Ctrl+.` is a binding, not a typed period — and `key`\n // only names the character typed when it names a single character at all.\n if (event.ctrlKey || event.metaKey || event.altKey) return null\n if (event.key.length !== 1) return null\n\n return item.commitCharacters?.includes(event.key) === true ? event.key : null\n}\n\n/**\n * The edit feature with `character` folded into whatever acceptance goes through it.\n *\n * One acceptance is one call and so one undo entry, which is the whole reason the character travels\n * inside it: inserted afterwards it would be an entry of its own, and undoing the completion would\n * leave it stranded on the word it was meant to follow.\n */\nexport function completionCommitFeature(\n feature: LanguageServerCompletionEditFeature,\n character: string | null,\n): LanguageServerCompletionEditFeature {\n if (character === null) return feature\n\n return {\n applyCompletion: (application) =>\n feature.applyCompletion(completionCommitApplication(application, character)),\n }\n}\n\n/**\n * The acceptance with the commit character appended to what the item inserts.\n *\n * The character is why the item was accepted, so it has to end up after the insertion exactly as it\n * was typed — `arr.fil` committed on `(` reads `arr.filter(`, and dropping the character is the one\n * outcome that makes the interaction worse than not having it.\n */\nfunction completionCommitApplication(\n application: LanguageServerCompletionApplication,\n character: string,\n): LanguageServerCompletionApplication {\n const [insertion, ...additional] = application.edits\n if (!insertion) return application\n\n const edits = [{ ...insertion, text: `${insertion.text}${character}` }].concat(additional)\n // A snippet's caret belongs on its first placeholder, and the character lands past the end of the\n // insertion, so every stop measured inside it is still where it was.\n if (application.snippetStops) return { ...application, edits }\n\n const head = application.selection.head + character.length\n return { edits, selection: { ...application.selection, anchor: head, head } }\n}\n"],"mappings":";;;;;;;;AAcA,SAAgB,0BACd,OACA,MACA,SACe;CACf,IAAI,CAAC,WAAW,CAAC,MAAM,OAAO;CAG9B,IAAI,MAAM,WAAW,MAAM,WAAW,MAAM,QAAQ,OAAO;CAC3D,IAAI,MAAM,IAAI,WAAW,GAAG,OAAO;CAEnC,OAAO,KAAK,kBAAkB,SAAS,MAAM,GAAG,MAAM,OAAO,MAAM,MAAM;AAC3E;;;;;;;;AASA,SAAgB,wBACd,SACA,WACqC;CACrC,IAAI,cAAc,MAAM,OAAO;CAE/B,OAAO,EACL,kBAAkB,gBAChB,QAAQ,gBAAgB,4BAA4B,aAAa,SAAS,CAAC,EAC/E;AACF;;;;;;;;AASA,SAAS,4BACP,aACA,WACqC;CACrC,MAAM,CAAC,WAAW,GAAG,cAAc,YAAY;CAC/C,IAAI,CAAC,WAAW,OAAO;CAEvB,MAAM,QAAQ,CAAC;EAAE,GAAG;EAAW,MAAM,GAAG,UAAU,OAAO;CAAY,CAAC,CAAC,CAAC,OAAO,U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qB;IAK7B,OAAO,CAAC,uBAAuB;IAQ/B,OAAO,CAAC,QAAQ,CAAC,yBAAyB,CAMzC;IAED;;;OAGG;IACI,aAAa,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAc3D;IAID,OAAO,CAAC,QAAQ,CAAC,4BAA4B,CAU5C;IAED,2FAA2F;IAC3F,OAAO,CAAC,aAAa;CAItB"}
@@ -1,6 +1,6 @@
1
1
  import { LANGUAGE_SERVER_COMPLETION_EDIT_FEATURE, completionAnchorRange, completionApplication, completionItemApplies, completionListResult, completionPrefix, completionTriggerFromChange, createCompletionWidgetController, rankCompletionItems } from "./completion.js";
2
2
  import { completionCommitCharacter, completionCommitFeature } from "./completionCommit.js";
3
- //#region src/completionController.ts
3
+ // src/completionController.ts
4
4
  /** The updates that move where the text is drawn without moving the text or the caret in it. */
5
5
  var VIEW_MOVEMENT_KINDS = /* @__PURE__ */ new Set(["layout", "viewport"]);
6
6
  /** The word the caret sits in, as the snapshot being handled has it. */
@@ -370,7 +370,6 @@ function completionSessionSurvives(session, caret) {
370
370
  if (caret.prefix.length === 0 && caret.offset < session.offset) return false;
371
371
  return caret.length - session.active.textSnapshot.length === caret.offset - session.offset;
372
372
  }
373
- //#endregion
374
373
  export { CompletionController };
375
374
 
376
375
  //# sourceMappingURL=completionController.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"completionProviders.d.ts","sourceRoot":"","sources":["../src/completionProviders.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,6BAA6B,EAClC,KAAK,kBAAkB,EACxB,MAAM,mCAAmC,CAAA;AAC1C,OAAO,EAEL,KAAK,SAAS,EACd,KAAK,uBAAuB,EAC7B,MAAM,uBAAuB,CAAA;AAC9B,OAAO,KAAK,KAAK,GAAG,MAAM,gCAAgC,CAAA;AAE1D,OAAO,EAA0B,KAAK,+BAA+B,EAAE,MAAM,cAAc,CAAA;AAS3F,uFAAuF;AACvF,MAAM,MAAM,uBAAu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AClF,MAAM,MAAM,yBAAyB,GAAG;IACtC,WAAW,CAAC,UAAU,EAAE,kBAAkB,CAAC,YAAY,CAAC,GAAG,SAAS,sBAAsB,EAAE,CAAA;CAC7F,CAAA;AAED,wBAAgB,oCAAoC,CAClD,MAAM,EAAE,SAAS,EACjB,WAAW,GAAE,MAAM,OAAoB,EACvC,gBAAgB,CAAC,EAAE,MAAM,IAAI,EAC7B,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI,GACxD,sBAAsB,CA0CxB;AAED;;;;;;;;;;GAUG;AACH,qBAAa,+BACX,YAAW,yBAAyB,EAAE,gBAAgB;IAKpD,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAJ1B,OAAO,CAAC,QAAQ,CAAC,aAAa,CAA6B;IAE3D,YACmB,OAAO,EAAE,6BAA6B,EACtC,OAAO,EAAE,SAAS,sBAAsB,EAAE,EAY5D;IAEM,WAAW,CAChB,UAAU,EAAE,kBAAkB,CAAC,YAAY,CAAC,GAC3C,SAAS,sBAAsB,EAAE,CAMnC;IAEM,OAAO,IAAI,IAAI,CAErB;CACF"}
@@ -1,7 +1,7 @@
1
1
  import { completionNeedsResolve } from "./completion.js";
2
- import { offsetToLspPositionInSnapshot } from "@singapore-editor/lsp";
3
2
  import { createEditorLanguageFeatureToken } from "@singapore-editor/core/extensions";
4
- //#region src/completionProviders.ts
3
+ import { offsetToLspPositionInSnapshot } from "@singapore-editor/lsp";
4
+ // src/completionProviders.ts
5
5
  var EDITOR_COMPLETION_SOURCE = createEditorLanguageFeatureToken("editor.completionSource");
6
6
  function createLanguageServerCompletionSource(client, isAvailable = () => true, onRequestSuccess, onRequestError) {
7
7
  return {
@@ -58,7 +58,6 @@ var LanguageServerCompletionSources = class {
58
58
  for (const registration of this.registrations) registration.dispose();
59
59
  }
60
60
  };
61
- //#endregion
62
61
  export { LanguageServerCompletionSources, createLanguageServerCompletionSource };
63
62
 
64
63
  //# sourceMappingURL=completionProviders.js.map
@@ -8,7 +8,7 @@ export type DefinitionLinkControllerOptions = {
8
8
  readonly linkHighlightNameNamespace?: string;
9
9
  readonly navigationTimingNamePrefix?: string;
10
10
  getActiveDocument(): ActiveDocument | null;
11
- onDefinitionLinkHover?(target: LanguageServerDefinitionTarget): void;
11
+ onDefinitionLinkHover?(target: LanguageServerDefinitionTarget): void | (() => void);
12
12
  onOpenDefinition?(target: LanguageServerDefinitionTarget, options?: LanguageServerNavigationOptions): void | boolean;
13
13
  onOpenReferences?(result: LanguageServerReferencesResult): void | boolean;
14
14
  onRequestError(error: unknown): void;
@@ -23,10 +23,12 @@ export declare class DefinitionLinkController {
23
23
  private readonly context;
24
24
  private readonly router;
25
25
  private readonly linkHighlightName;
26
+ private readonly lifetime;
26
27
  private definitionRequestId;
27
28
  private definitionHoverRequestId;
28
29
  private lastPointerOffset;
29
30
  private linkRange;
31
+ private definitionLinkDisposer;
30
32
  private disposed;
31
33
  private pressParticipant;
32
34
  constructor(options: DefinitionLinkControllerOptions);
@@ -47,6 +49,7 @@ export declare class DefinitionLinkController {
47
49
  private handleNavigationResult;
48
50
  private handleReferencesResult;
49
51
  private openNavigationTarget;
52
+ private navigationIsCurrent;
50
53
  private navigationTimingName;
51
54
  private openDefinitionTarget;
52
55
  private clearDefinitionLink;
@@ -1 +1 @@
1
- {"version":3,"file":"definitionLinkController.d.ts","sourceRoot":"","sources":["../src/definitionLinkController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,6BAA6B,EAC7B,gCAAgC,EAChC,kBAAkB,EACnB,MAAM,mCAAmC,CAAA;AAe1C,OAAO,KAAK,EAAE,cAAc,EAAE,+BAA+B,EAAE,MAAM,eAAe,CAAA;AACpF,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAA;AAC9D,OAAO,KAAK,EACV,8BAA8B,EAE9B,+BAA+B,EAC/B,8BAA8B,EAC/B,MA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