@singapore-editor/lsp-plugin 0.2.13 → 0.2.15
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.
- package/dist/codeActions.js.map +1 -1
- package/dist/colorAlpha.js.map +1 -1
- package/dist/completion.js.map +1 -1
- package/dist/completionCommit.js.map +1 -1
- package/dist/completionController.js.map +1 -1
- package/dist/completionProviders.js.map +1 -1
- package/dist/definitionLinkController.d.ts.map +1 -1
- package/dist/definitionLinkController.js +4 -2
- package/dist/definitionLinkController.js.map +1 -1
- package/dist/definitionNavigation.js +4 -4
- package/dist/definitionNavigation.js.map +1 -1
- package/dist/diagnosticNotes.js.map +1 -1
- package/dist/diagnosticProjection.js.map +1 -1
- package/dist/diagnostics.js.map +1 -1
- package/dist/diagnosticsPresenter.js.map +1 -1
- package/dist/document.js.map +1 -1
- package/dist/documentHighlightController.js.map +1 -1
- package/dist/documentSnapshot.js.map +1 -1
- package/dist/documentSync.js +2 -2
- package/dist/documentSync.js.map +1 -1
- package/dist/documentSyncController.js.map +1 -1
- package/dist/formatOnType.js.map +1 -1
- package/dist/formatting.js.map +1 -1
- package/dist/fuzzyMatch.js.map +1 -1
- package/dist/hoverParticipant.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/keyCommands.js.map +1 -1
- package/dist/lane.js.map +1 -1
- package/dist/lspConnection.d.ts +16 -0
- package/dist/lspConnection.d.ts.map +1 -1
- package/dist/lspConnection.js +51 -3
- package/dist/lspConnection.js.map +1 -1
- package/dist/lspConnectionPool.d.ts.map +1 -1
- package/dist/lspConnectionPool.js +33 -5
- package/dist/lspConnectionPool.js.map +1 -1
- package/dist/minimalEdits.js.map +1 -1
- package/dist/paths.d.ts +13 -0
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +44 -2
- package/dist/paths.js.map +1 -1
- package/dist/plugin.d.ts +6 -1
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +1 -0
- package/dist/plugin.js.map +1 -1
- package/dist/plugin.styles.js.map +1 -1
- package/dist/pullDiagnostics.js.map +1 -1
- package/dist/renameWidget.js.map +1 -1
- package/dist/retainedSource.js.map +1 -1
- package/dist/semanticTokenDecoder.js.map +1 -1
- package/dist/semanticTokens.js.map +1 -1
- package/dist/serverSet.js.map +1 -1
- package/dist/signatureHelp.js.map +1 -1
- package/dist/signatureHelpController.js.map +1 -1
- package/dist/sourceConnection.js.map +1 -1
- package/dist/sourceText.js.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/viewDocumentSnapshot.js.map +1 -1
- package/dist/workspaceEdit.js.map +1 -1
- package/dist/workspaceEditProvenance.js.map +1 -1
- package/dist/workspaceTextEdits.js.map +1 -1
- package/package.json +7 -7
package/dist/lspConnection.js
CHANGED
|
@@ -15,6 +15,12 @@ var LspConnection = class {
|
|
|
15
15
|
reconnectAttempts = 0;
|
|
16
16
|
readyAt = null;
|
|
17
17
|
reconnectTimer = null;
|
|
18
|
+
/** Settles when the server behind the attached transport is gone; null when it has none. */
|
|
19
|
+
transportGone = null;
|
|
20
|
+
/** The same for the last closed transport, kept until it settles: the next start waits for it. */
|
|
21
|
+
retiring = null;
|
|
22
|
+
/** A start is under way: waiting on `retiring`, or in the factory, until a transport attaches. */
|
|
23
|
+
starting = false;
|
|
18
24
|
/** Why the server said it is going, reported as the reason for the close that follows. */
|
|
19
25
|
exit = null;
|
|
20
26
|
constructor(options, callbacks) {
|
|
@@ -22,10 +28,21 @@ var LspConnection = class {
|
|
|
22
28
|
this.callbacks = callbacks;
|
|
23
29
|
this.client = this.createClient();
|
|
24
30
|
}
|
|
31
|
+
/** Starts the connection. A no-op while it is connected or already on its way to being. */
|
|
25
32
|
connect() {
|
|
33
|
+
if (this.transport || this.starting) return;
|
|
34
|
+
if (this.reconnectTimer !== null) clearTimeout(this.reconnectTimer);
|
|
35
|
+
this.reconnectTimer = null;
|
|
26
36
|
this.setStatus("loading");
|
|
27
37
|
this.connectTransport();
|
|
28
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* Pending while the server behind this connection's last closed transport is still going, null
|
|
41
|
+
* otherwise. It never rejects. Whoever starts another server for the same work waits for it.
|
|
42
|
+
*/
|
|
43
|
+
get retirement() {
|
|
44
|
+
return this.retiring;
|
|
45
|
+
}
|
|
29
46
|
dispose() {
|
|
30
47
|
if (this.disposed) return;
|
|
31
48
|
this.disposed = true;
|
|
@@ -34,8 +51,7 @@ var LspConnection = class {
|
|
|
34
51
|
this.removeTransportCloseListener?.();
|
|
35
52
|
this.removeTransportCloseListener = null;
|
|
36
53
|
this.client.disconnect();
|
|
37
|
-
this.
|
|
38
|
-
this.transport = null;
|
|
54
|
+
this.closeTransport();
|
|
39
55
|
this.setStatus("idle");
|
|
40
56
|
}
|
|
41
57
|
createClient() {
|
|
@@ -75,7 +91,19 @@ var LspConnection = class {
|
|
|
75
91
|
}
|
|
76
92
|
});
|
|
77
93
|
}
|
|
94
|
+
/** The one gate every start goes through: one at a time, and never beside a server still going. */
|
|
78
95
|
connectTransport() {
|
|
96
|
+
if (this.transport || this.starting) return;
|
|
97
|
+
this.starting = true;
|
|
98
|
+
const retiring = this.retiring;
|
|
99
|
+
if (retiring) {
|
|
100
|
+
retiring.then(this.startTransport);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
this.startTransport();
|
|
104
|
+
}
|
|
105
|
+
startTransport = () => {
|
|
106
|
+
if (this.disposed) return;
|
|
79
107
|
try {
|
|
80
108
|
const transport = this.options.createTransport();
|
|
81
109
|
if (isTransportPromise(transport)) {
|
|
@@ -88,13 +116,16 @@ var LspConnection = class {
|
|
|
88
116
|
} catch (error) {
|
|
89
117
|
this.handleConnectError(error);
|
|
90
118
|
}
|
|
91
|
-
}
|
|
119
|
+
};
|
|
92
120
|
connectManagedTransport(transport) {
|
|
121
|
+
this.starting = false;
|
|
122
|
+
const gone = settled(transport.gone);
|
|
93
123
|
if (this.disposed) {
|
|
94
124
|
transport.close();
|
|
95
125
|
return;
|
|
96
126
|
}
|
|
97
127
|
this.transport = transport;
|
|
128
|
+
this.transportGone = gone;
|
|
98
129
|
this.exit = null;
|
|
99
130
|
this.removeTransportCloseListener = transport.onDidClose((error) => this.handleTransportClose(error));
|
|
100
131
|
transport.subscribe(this.forgetExitOnLaterMessage);
|
|
@@ -115,6 +146,7 @@ var LspConnection = class {
|
|
|
115
146
|
this.callbacks.onConnected();
|
|
116
147
|
}
|
|
117
148
|
handleConnectError(error) {
|
|
149
|
+
this.starting = false;
|
|
118
150
|
if (this.disposed) return;
|
|
119
151
|
this.detachTransport();
|
|
120
152
|
this.giveUpOrReconnect(error);
|
|
@@ -135,8 +167,19 @@ var LspConnection = class {
|
|
|
135
167
|
this.removeTransportCloseListener = null;
|
|
136
168
|
this.transport?.unsubscribe(this.forgetExitOnLaterMessage);
|
|
137
169
|
this.client.disconnect();
|
|
170
|
+
this.closeTransport();
|
|
171
|
+
}
|
|
172
|
+
/** Closes the transport and keeps its server's going as what the next start waits for. */
|
|
173
|
+
closeTransport() {
|
|
138
174
|
this.transport?.close();
|
|
139
175
|
this.transport = null;
|
|
176
|
+
const gone = this.transportGone;
|
|
177
|
+
this.transportGone = null;
|
|
178
|
+
if (!gone) return;
|
|
179
|
+
this.retiring = gone;
|
|
180
|
+
gone.then(() => {
|
|
181
|
+
if (this.retiring === gone) this.retiring = null;
|
|
182
|
+
});
|
|
140
183
|
}
|
|
141
184
|
giveUpOrReconnect(error) {
|
|
142
185
|
if (this.scheduleReconnect(error)) return;
|
|
@@ -182,6 +225,11 @@ function createWorkerLspTransportFactory(workerFactory) {
|
|
|
182
225
|
function now() {
|
|
183
226
|
return typeof performance === "undefined" ? Date.now() : performance.now();
|
|
184
227
|
}
|
|
228
|
+
/** `gone` as a signal only: a server that failed to go is still not one to wait on any longer. */
|
|
229
|
+
function settled(gone) {
|
|
230
|
+
return gone ? gone.then(ignore, ignore) : null;
|
|
231
|
+
}
|
|
232
|
+
var ignore = () => void 0;
|
|
185
233
|
function isTransportPromise(value) {
|
|
186
234
|
return typeof value.then === "function";
|
|
187
235
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lspConnection.js","names":[],"sources":["../src/lspConnection.ts"],"sourcesContent":["import {\n createWebSocketLspTransport,\n createWorkerLspTransport,\n LSP_SERVER_EXITED,\n LspClient,\n LspServerExitedError,\n LspWorkspace,\n type LspServerExitedParams,\n type LspManagedTransport,\n type LspNotificationHandler,\n type LspServerRequestHandler,\n type LspWebSocketTransportOptions,\n type LspWorkerLike,\n} from '@singapore-editor/lsp'\nimport type * as lsp from 'vscode-languageserver-protocol'\n\nimport type { LanguageServerStatus } from './types'\n\nconst DIAGNOSTIC_REFRESH_METHOD = 'workspace/diagnostic/refresh'\n/** A connection that stayed up this long ended a crash streak; its next loss starts a new one. */\nconst STABLE_CONNECTION_MS = 60_000\n\nexport type LspReconnectOptions = {\n /** One delay per attempt; when they run out the connection gives up and reports unavailable. */\n readonly delaysMs: readonly number[]\n}\n\nexport type LspConnectionTransportFactory = () => LspManagedTransport | Promise<LspManagedTransport>\n\nexport type LspConnectionOptions = {\n readonly rootUri: lsp.DocumentUri | null\n readonly initializationOptions: unknown\n readonly timeoutMs: number\n /**\n * Merged over `defaultClientCapabilities()` by the client itself, so a host declares only what it\n * adds. This is how a host turns on a feature the defaults deliberately leave off —\n * `textDocument.semanticTokens` among them, which no server sends without being asked.\n */\n readonly capabilities?: lsp.ClientCapabilities\n /**\n * Load-bearing rather than cosmetic: at least one real server branches on the client name and\n * withholds a request from clients it does not recognise. The value is the host's to pick.\n */\n readonly clientInfo?: lsp.InitializeParams['clientInfo']\n /**\n * Merged around the connection's own handlers rather than replacing them. See createClient.\n */\n readonly notificationHandlers?: Readonly<Record<string, LspNotificationHandler<LspClient>>>\n /** Answers the server's requests; the connection's own `workspace/diagnostic/refresh` stays its. */\n readonly serverRequestHandlers?: Readonly<Record<string, LspServerRequestHandler<LspClient>>>\n /** Reconnects a transport that closed or failed on its own. Absent, the first loss is final. */\n readonly reconnect?: LspReconnectOptions\n createTransport(): LspManagedTransport | Promise<LspManagedTransport>\n}\n\nexport type LspConnectionCallbacks = {\n /** Also called again after a reconnect: the client re-initialized and re-opened its documents. */\n onConnected(): void\n onDiagnosticRefresh?(): void\n /** The transport is gone and another is on its way; what the server said so far is stale. */\n onReconnecting?(error: unknown): void\n onUnavailable(): void\n onPublishDiagnostics(params: unknown): void\n onStatusChange?: (status: LanguageServerStatus) => void\n onError?: (error: unknown) => void\n}\n\n/** A connection a view borrows. `release` ends its interest; closing is the provider's call. */\nexport type LspConnectionLease = {\n readonly connection: LspConnection\n release(): void\n}\n\n/**\n * Supplies connections that outlive one view, so a file switch does not pay a handshake and an\n * `initialize` round trip. `options` is the connection the plugin would have built: build from it on\n * a new key, ignore it on a known one.\n *\n * **`callbacks.onConnected` must never fire synchronously from `acquire`** — the caller is\n * mid-construction. Replay it on a microtask.\n */\nexport type LspConnectionProvider = {\n acquire(options: LspConnectionOptions, callbacks: LspConnectionCallbacks): LspConnectionLease\n}\n\nexport class LspConnection {\n public readonly workspace = new LspWorkspace()\n public readonly client: LspClient\n\n private transport: LspManagedTransport | null = null\n private removeTransportCloseListener: (() => void) | null = null\n private disposed = false\n private status: LanguageServerStatus = 'idle'\n private reconnectAttempts = 0\n private readyAt: number | null = null\n private reconnectTimer: ReturnType<typeof setTimeout> | null = null\n /** Why the server said it is going, reported as the reason for the close that follows. */\n private exit: LspServerExitedParams | null = null\n\n public constructor(\n private readonly options: LspConnectionOptions,\n private readonly callbacks: LspConnectionCallbacks,\n ) {\n this.client = this.createClient()\n }\n\n public connect(): void {\n this.setStatus('loading')\n this.connectTransport()\n }\n\n public dispose(): void {\n if (this.disposed) return\n\n this.disposed = true\n if (this.reconnectTimer !== null) clearTimeout(this.reconnectTimer)\n this.reconnectTimer = null\n this.removeTransportCloseListener?.()\n this.removeTransportCloseListener = null\n this.client.disconnect()\n this.transport?.close()\n this.transport = null\n this.setStatus('idle')\n }\n\n private createClient(): LspClient {\n const hostHandlers = this.options.notificationHandlers\n return new LspClient({\n rootUri: this.options.rootUri,\n workspaceFolders: null,\n workspace: this.workspace,\n timeoutMs: this.options.timeoutMs,\n initializationOptions: this.options.initializationOptions,\n capabilities: this.options.capabilities,\n clientInfo: this.options.clientInfo,\n // Host handlers are merged *around* the connection's own rather than replacing them: the\n // whole diagnostics feature hangs off publishDiagnostics, so a host that happens to want that\n // notification too must not be able to take it away. Its handler runs after ours.\n notificationHandlers: {\n ...hostHandlers,\n [DIAGNOSTIC_REFRESH_METHOD]: (client, params, message) => {\n this.callbacks.onDiagnosticRefresh?.()\n hostHandlers?.[DIAGNOSTIC_REFRESH_METHOD]?.(client, params, message)\n return true\n },\n [LSP_SERVER_EXITED]: (client, params, message) => {\n this.exit = serverExitedParams(params)\n hostHandlers?.[LSP_SERVER_EXITED]?.(client, params, message)\n return true\n },\n 'textDocument/publishDiagnostics': (client, params, message) => {\n this.callbacks.onPublishDiagnostics(params)\n hostHandlers?.['textDocument/publishDiagnostics']?.(client, params, message)\n return true\n },\n },\n serverRequestHandlers: {\n ...this.options.serverRequestHandlers,\n [DIAGNOSTIC_REFRESH_METHOD]: () => {\n this.callbacks.onDiagnosticRefresh?.()\n return null\n },\n },\n })\n }\n\n private connectTransport(): void {\n try {\n const transport = this.options.createTransport()\n if (isTransportPromise(transport)) {\n void transport\n .then((value) => this.connectManagedTransport(value))\n .catch((error) => {\n this.handleConnectError(error)\n })\n return\n }\n\n this.connectManagedTransport(transport)\n } catch (error) {\n this.handleConnectError(error)\n }\n }\n\n private connectManagedTransport(transport: LspManagedTransport): void {\n if (this.disposed) {\n transport.close()\n return\n }\n\n this.transport = transport\n this.exit = null\n this.removeTransportCloseListener = transport.onDidClose((error) =>\n this.handleTransportClose(error),\n )\n transport.subscribe(this.forgetExitOnLaterMessage)\n // Only while this transport is still the connection's: a close that already detached it made\n // the report, and the initialize it rejected on the way out must not make a second one.\n void this.client\n .connect(transport)\n .then(() => {\n if (this.transport === transport) this.handleConnected()\n })\n .catch((error: unknown) => {\n if (this.transport === transport) this.handleConnectError(error)\n })\n }\n\n /** A server that says anything after announcing its exit did not exit; a later close is its own. */\n private readonly forgetExitOnLaterMessage = (message: string): void => {\n if (this.exit && !message.includes(LSP_SERVER_EXITED)) this.exit = null\n }\n\n private handleConnected(): void {\n if (this.disposed) return\n\n this.readyAt = now()\n this.setStatus('ready')\n this.callbacks.onConnected()\n }\n\n private handleConnectError(error: unknown): void {\n if (this.disposed) return\n\n this.detachTransport()\n this.giveUpOrReconnect(error)\n }\n\n private handleTransportClose(error?: unknown): void {\n if (this.disposed) return\n\n const exit = this.exit\n this.exit = null\n this.detachTransport()\n if (exit) {\n this.giveUpOrReconnect(new LspServerExitedError(exit))\n return\n }\n this.giveUpOrReconnect(error ?? new Error('LSP transport closed'))\n }\n\n private detachTransport(): void {\n this.removeTransportCloseListener?.()\n this.removeTransportCloseListener = null\n this.transport?.unsubscribe(this.forgetExitOnLaterMessage)\n this.client.disconnect()\n this.transport?.close()\n this.transport = null\n }\n\n private giveUpOrReconnect(error: unknown): void {\n if (this.scheduleReconnect(error)) return\n\n this.setStatus('error')\n this.callbacks.onUnavailable()\n this.handleError(error)\n }\n\n private scheduleReconnect(error: unknown): boolean {\n if (this.readyAt !== null && now() - this.readyAt >= STABLE_CONNECTION_MS) {\n this.reconnectAttempts = 0\n }\n this.readyAt = null\n const delay = this.options.reconnect?.delaysMs[this.reconnectAttempts]\n if (delay === undefined) return false\n\n this.reconnectAttempts += 1\n this.setStatus('loading')\n this.callbacks.onReconnecting?.(error)\n // @justification A reconnect backoff, not rendering work: the handle is kept, cleared on dispose,\n // and a disposed connection ignores it.\n this.reconnectTimer = setTimeout(() => {\n this.reconnectTimer = null\n if (!this.disposed) this.connectTransport()\n }, delay)\n return true\n }\n\n private setStatus(status: LanguageServerStatus): void {\n if (this.status === status) return\n\n this.status = status\n this.callbacks.onStatusChange?.(status)\n }\n\n private handleError(error: unknown): void {\n this.callbacks.onError?.(error)\n }\n}\n\nexport function createWebSocketLspTransportFactory(\n route: string | URL,\n options?: LspWebSocketTransportOptions,\n): LspConnectionTransportFactory {\n return () =>\n createWebSocketLspTransport(route, {\n protocols: options?.protocols,\n WebSocketCtor: options?.WebSocketCtor,\n })\n}\n\nexport function createWorkerLspTransportFactory(\n workerFactory: () => LspWorkerLike,\n): LspConnectionTransportFactory {\n return () =>\n createWorkerLspTransport(workerFactory(), {\n messageFormat: 'json',\n terminateOnClose: true,\n })\n}\n\nfunction now(): number {\n return typeof performance === 'undefined' ? Date.now() : performance.now()\n}\n\nfunction isTransportPromise(\n value: LspManagedTransport | Promise<LspManagedTransport>,\n): value is Promise<LspManagedTransport> {\n return typeof (value as Promise<LspManagedTransport>).then === 'function'\n}\n\nfunction serverExitedParams(params: unknown): LspServerExitedParams | null {\n if (typeof params !== 'object' || params === null) return null\n const outcome = (params as { outcome?: unknown }).outcome\n return typeof outcome === 'string' ? (params as LspServerExitedParams) : null\n}\n"],"mappings":";;AAkBA,IAAM,4BAA4B;;AAElC,IAAM,uBAAuB;AAiE7B,IAAa,gBAAb,MAA2B;CAeN;CACA;CAfnB,YAA4B,IAAI,aAAa;CAC7C;CAEA,YAAgD;CAChD,+BAA4D;CAC5D,WAAmB;CACnB,SAAuC;CACvC,oBAA4B;CAC5B,UAAiC;CACjC,iBAA+D;;CAE/D,OAA6C;CAE7C,YACE,SACA,WACA;EAFiB,KAAA,UAAA;EACA,KAAA,YAAA;EAEjB,KAAK,SAAS,KAAK,aAAa;CAClC;CAEA,UAAuB;EACrB,KAAK,UAAU,SAAS;EACxB,KAAK,iBAAiB;CACxB;CAEA,UAAuB;EACrB,IAAI,KAAK,UAAU;EAEnB,KAAK,WAAW;EAChB,IAAI,KAAK,mBAAmB,MAAM,aAAa,KAAK,cAAc;EAClE,KAAK,iBAAiB;EACtB,KAAK,+BAA+B;EACpC,KAAK,+BAA+B;EACpC,KAAK,OAAO,WAAW;EACvB,KAAK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T,QAAQ,GACR,OAAO,GACP,UAAU,GACV,QAAQ,GACR,SAAS,GACT,cAAc,GACd,OAAO,GACP,iBAAiB,CAAA;IACrB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,MAAM,EAAE,oBAAoB,CAAA;IACrC,0GAA0G;IAC1G,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAA;IAC5B,QAAQ,CAAC,YAAY,CAAC,EAAE,OAAO,CAAA;IAC/B,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAA;IACxB,6EAA6E;IAC7E,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;CACrC,CAAA;AAED,MAAM,MAAM,wBAAwB,GAAG;IACrC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAA;IAC7B,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,sBAAsB,KAAK,IAAI,CAAA;CAC3D,CAAA;AAiCD;;;;GAIG;AACH,qBAAa,iBAAiB;;IAO5B,YAAmB,OAAO,GAAE,wBAA6B,EAGxD;IAED,kEAAkE;IAC3D,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,qBAAqB,CAElD;IAEM,OAAO,CACZ,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,oBAAoB,EAC7B,SAAS,EAAE,sBAAsB,GAChC,kBAAkB,CAwBpB;IAED,gFAAgF;IACzE,OAAO,IAAI,IAAI,CAOrB;CA6MF"}
|
|
@@ -13,6 +13,8 @@ var DEFAULT_IDLE_GRACE_MS = 3e4;
|
|
|
13
13
|
*/
|
|
14
14
|
var LspConnectionPool = class {
|
|
15
15
|
#entries = /* @__PURE__ */ new Map();
|
|
16
|
+
/** Per key, the going of a server whose connection is already disposed. Cleared when it settles. */
|
|
17
|
+
#retiring = /* @__PURE__ */ new Map();
|
|
16
18
|
#idleGraceMs;
|
|
17
19
|
#onEvent;
|
|
18
20
|
constructor(options = {}) {
|
|
@@ -47,11 +49,36 @@ var LspConnectionPool = class {
|
|
|
47
49
|
}
|
|
48
50
|
/** Closes every connection. For teardown and for tests, not for routine use. */
|
|
49
51
|
dispose() {
|
|
50
|
-
|
|
52
|
+
const entries = Array.from(this.#entries.values());
|
|
53
|
+
this.#entries.clear();
|
|
54
|
+
for (const entry of entries) {
|
|
51
55
|
if (entry.idleTimer !== null) clearTimeout(entry.idleTimer);
|
|
52
|
-
entry
|
|
56
|
+
this.#disposeConnection(entry);
|
|
53
57
|
}
|
|
54
|
-
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Disposes the connection and remembers, by key, a server of it that is still going. Nothing
|
|
61
|
+
* here waits: the next connection for the key does, before it asks for its first transport.
|
|
62
|
+
*/
|
|
63
|
+
#disposeConnection(entry) {
|
|
64
|
+
entry.connection.dispose();
|
|
65
|
+
const gone = entry.connection.retirement;
|
|
66
|
+
if (!gone) return;
|
|
67
|
+
this.#retiring.set(entry.key, gone);
|
|
68
|
+
gone.then(() => {
|
|
69
|
+
if (this.#retiring.get(entry.key) === gone) this.#retiring.delete(entry.key);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
/** The host's factory, held back while the key's previous server is still going. */
|
|
73
|
+
#gatedFactory(entry, createTransport) {
|
|
74
|
+
return () => {
|
|
75
|
+
const retiring = this.#retiring.get(entry.key);
|
|
76
|
+
if (!retiring) return createTransport();
|
|
77
|
+
return retiring.then(() => {
|
|
78
|
+
if (this.#entries.get(entry.key) !== entry) throw new Error("LSP connection was closed");
|
|
79
|
+
return createTransport();
|
|
80
|
+
});
|
|
81
|
+
};
|
|
55
82
|
}
|
|
56
83
|
#create(key, options) {
|
|
57
84
|
const notificationMethods = new Set(Object.keys(options.notificationHandlers ?? {}));
|
|
@@ -69,6 +96,7 @@ var LspConnectionPool = class {
|
|
|
69
96
|
};
|
|
70
97
|
entry.connection = new LspConnection({
|
|
71
98
|
...options,
|
|
99
|
+
createTransport: this.#gatedFactory(entry, () => options.createTransport()),
|
|
72
100
|
notificationHandlers: this.#dispatchers(entry, notificationMethods),
|
|
73
101
|
serverRequestHandlers: requestDispatchers(entry, options.serverRequestHandlers ?? {})
|
|
74
102
|
}, this.#fanOut(entry));
|
|
@@ -157,7 +185,7 @@ var LspConnectionPool = class {
|
|
|
157
185
|
if (entry.leases.size > 0) return;
|
|
158
186
|
if (this.#entries.get(entry.key) !== entry) return;
|
|
159
187
|
this.#entries.delete(entry.key);
|
|
160
|
-
entry
|
|
188
|
+
this.#disposeConnection(entry);
|
|
161
189
|
this.#emit(entry, "closed", {
|
|
162
190
|
durationMs: Math.round(now() - entry.createdAt),
|
|
163
191
|
reachedReady: entry.readyAt !== null
|
|
@@ -167,7 +195,7 @@ var LspConnectionPool = class {
|
|
|
167
195
|
if (entry.idleTimer !== null) clearTimeout(entry.idleTimer);
|
|
168
196
|
entry.idleTimer = null;
|
|
169
197
|
if (this.#entries.get(entry.key) === entry) this.#entries.delete(entry.key);
|
|
170
|
-
entry
|
|
198
|
+
this.#disposeConnection(entry);
|
|
171
199
|
this.#emit(entry, "retired", {
|
|
172
200
|
durationMs: Math.round(now() - entry.createdAt),
|
|
173
201
|
reachedReady: entry.readyAt !== null
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lspConnectionPool.js","names":[],"sources":["../src/lspConnectionPool.ts"],"sourcesContent":["import type {\n LspClient,\n LspNotificationHandler,\n LspServerRequestHandler,\n} from '@singapore-editor/lsp'\n\nimport {\n LspConnection,\n type LspConnectionCallbacks,\n type LspConnectionLease,\n type LspConnectionOptions,\n type LspConnectionProvider,\n} from './lspConnection'\nimport type { LanguageServerStatus } from './types'\n\n/**\n * How long a connection with no borrowers is kept. A file switch drops the lease count to zero for a\n * tick or two on its way from one view to the next; the cost of holding on is one idle socket, the\n * cost of letting go early is another handshake against a server that may still be indexing.\n */\nconst DEFAULT_IDLE_GRACE_MS = 30_000\n\n/** What a pooled connection just did, for a host that wants to log it. */\nexport type LspConnectionPoolEvent = {\n readonly kind:\n | 'created'\n | 'reused'\n | 'ready'\n | 'released'\n | 'closed'\n | 'retired'\n | 'reconnecting'\n | 'error'\n | 'handler_ignored'\n readonly key: string\n readonly leaseCount: number\n readonly status: LanguageServerStatus\n /** Time to `initialize` for `ready`; the connection's life so far for `closed`, `retired` and `error`. */\n readonly durationMs?: number\n readonly reachedReady?: boolean\n readonly error?: unknown\n /** Methods a late borrower declared that this connection cannot dispatch. */\n readonly methods?: readonly string[]\n}\n\nexport type LspConnectionPoolOptions = {\n readonly idleGraceMs?: number\n readonly onEvent?: (event: LspConnectionPoolEvent) => void\n}\n\ntype NotificationHandlers = Readonly<Record<string, LspNotificationHandler<LspClient>>>\ntype ServerRequestHandlers = Readonly<Record<string, LspServerRequestHandler<LspClient>>>\n\n/** Handlers are per borrower: the first one's are bound to a view the reader may have left. */\ntype ConnectionLease = {\n readonly callbacks: LspConnectionCallbacks\n readonly notificationHandlers: NotificationHandlers\n readonly serverRequestHandlers: ServerRequestHandlers\n}\n\ntype PooledConnection = {\n readonly initializationContract: ImmutableInitializationContract\n readonly key: string\n readonly leases: Set<ConnectionLease>\n readonly createdAt: number\n /** Fixed at construction, when the client reads the record. A later borrower outside it is a defect. */\n readonly notificationMethods: ReadonlySet<string>\n connection: LspConnection\n status: LanguageServerStatus\n connected: boolean\n readyAt: number | null\n idleTimer: ReturnType<typeof setTimeout> | null\n}\n\ntype ImmutableInitializationContract = {\n readonly capabilities: unknown\n readonly clientInfo: unknown\n readonly initializationOptions: unknown\n readonly rootUri: string | null\n}\n\n/**\n * One connection per key, outliving the views that borrow it. A view contribution is rebuilt on\n * every file switch, and a connection it owns dies with it — thirteen handshakes in twenty-two\n * seconds, measured. The key is opaque: how a server session is named is the host's vocabulary.\n */\nexport class LspConnectionPool {\n readonly #entries = new Map<string, PooledConnection>()\n readonly #idleGraceMs: number\n readonly #onEvent?: (event: LspConnectionPoolEvent) => void\n\n public constructor(options: LspConnectionPoolOptions = {}) {\n this.#idleGraceMs = options.idleGraceMs ?? DEFAULT_IDLE_GRACE_MS\n this.#onEvent = options.onEvent\n }\n\n /** A provider bound to one key, in the shape the plugin takes. */\n public provider(key: string): LspConnectionProvider {\n return { acquire: (options, callbacks) => this.acquire(key, options, callbacks) }\n }\n\n public acquire(\n key: string,\n options: LspConnectionOptions,\n callbacks: LspConnectionCallbacks,\n ): LspConnectionLease {\n const existing = this.#entries.get(key)\n if (existing) this.#assertCompatible(existing, options)\n\n const entry = existing ?? this.#create(key, options)\n if (entry.idleTimer !== null) {\n clearTimeout(entry.idleTimer)\n entry.idleTimer = null\n }\n\n const lease: ConnectionLease = {\n callbacks,\n notificationHandlers: options.notificationHandlers ?? {},\n serverRequestHandlers: options.serverRequestHandlers ?? {},\n }\n this.#reportUndispatchable(entry, lease)\n entry.leases.add(lease)\n this.#emit(entry, existing ? 'reused' : 'created')\n this.#replayTo(entry, lease)\n\n return {\n connection: entry.connection,\n release: () => this.#release(entry, lease),\n }\n }\n\n /** Closes every connection. For teardown and for tests, not for routine use. */\n public dispose(): void {\n for (const entry of this.#entries.values()) {\n if (entry.idleTimer !== null) clearTimeout(entry.idleTimer)\n entry.connection.dispose()\n }\n this.#entries.clear()\n }\n\n #create(key: string, options: LspConnectionOptions): PooledConnection {\n const notificationMethods = new Set(Object.keys(options.notificationHandlers ?? {}))\n const entry: PooledConnection = {\n connected: false,\n connection: null as unknown as LspConnection,\n createdAt: now(),\n idleTimer: null,\n initializationContract: initializationContract(options),\n key,\n leases: new Set(),\n notificationMethods,\n readyAt: null,\n status: 'idle',\n }\n // Assigned after the record exists because the callbacks close over it: the\n // connection reports `loading` from inside `connect()`, which is before any\n // `new LspConnection(...)` expression could have returned.\n entry.connection = new LspConnection(\n {\n ...options,\n notificationHandlers: this.#dispatchers(entry, notificationMethods),\n serverRequestHandlers: requestDispatchers(entry, options.serverRequestHandlers ?? {}),\n },\n this.#fanOut(entry),\n )\n this.#entries.set(key, entry)\n entry.connection.connect()\n\n return entry\n }\n\n #assertCompatible(entry: PooledConnection, options: LspConnectionOptions): void {\n const incoming = initializationContract(options)\n if (structurallyEqual(entry.initializationContract, incoming)) return\n\n throw new Error(\n `LSP connection pool key \"${entry.key}\" already has a different initialization contract.`,\n )\n }\n\n /** Handled is the disjunction: one view claiming a notification must not hide it from another. */\n #dispatchers(entry: PooledConnection, methods: ReadonlySet<string>): NotificationHandlers {\n const handlers: Record<string, LspNotificationHandler<LspClient>> = {}\n for (const method of methods) {\n handlers[method] = (client, params, message) => {\n let handled = false\n for (const lease of leasesOf(entry))\n handled =\n (lease.notificationHandlers[method]?.(client, params, message) ?? false) || handled\n\n return handled\n }\n }\n\n return handlers\n }\n\n /** Diagnostics broadcast rather than routed: `DocumentSync` already drops uris it does not hold. */\n #fanOut(entry: PooledConnection): LspConnectionCallbacks {\n return {\n onConnected: () => {\n entry.connected = true\n entry.readyAt = now()\n this.#emit(entry, 'ready', { durationMs: Math.round(entry.readyAt - entry.createdAt) })\n for (const lease of leasesOf(entry)) lease.callbacks.onConnected()\n },\n onDiagnosticRefresh: () => {\n for (const lease of leasesOf(entry)) lease.callbacks.onDiagnosticRefresh?.()\n },\n onReconnecting: (error) => {\n entry.connected = false\n this.#emit(entry, 'reconnecting', {\n durationMs: Math.round(now() - entry.createdAt),\n error,\n reachedReady: entry.readyAt !== null,\n })\n for (const lease of leasesOf(entry)) lease.callbacks.onReconnecting?.(error)\n },\n onUnavailable: () => {\n entry.connected = false\n this.#retire(entry)\n for (const lease of leasesOf(entry)) lease.callbacks.onUnavailable()\n },\n onPublishDiagnostics: (params) => {\n for (const lease of leasesOf(entry)) lease.callbacks.onPublishDiagnostics(params)\n },\n onStatusChange: (status) => {\n entry.status = status\n for (const lease of leasesOf(entry)) lease.callbacks.onStatusChange?.(status)\n },\n onError: (error) => {\n this.#emit(entry, 'error', {\n durationMs: Math.round(now() - entry.createdAt),\n error,\n reachedReady: entry.readyAt !== null,\n })\n for (const lease of leasesOf(entry)) lease.callbacks.onError?.(error)\n },\n }\n }\n\n /** A microtask, not a straight call: `acquire` runs inside the contribution's constructor. */\n #replayTo(entry: PooledConnection, lease: ConnectionLease): void {\n if (entry.status === 'idle') return\n\n const status = entry.status\n const connected = entry.connected\n queueMicrotask(() => {\n if (!entry.leases.has(lease)) return\n\n lease.callbacks.onStatusChange?.(status)\n if (connected) lease.callbacks.onConnected()\n })\n }\n\n #release(entry: PooledConnection, lease: ConnectionLease): void {\n if (!entry.leases.delete(lease)) return\n\n this.#emit(entry, 'released')\n if (entry.leases.size > 0) return\n if (this.#entries.get(entry.key) !== entry) return\n\n entry.idleTimer = setTimeout(() => this.#closeIdle(entry), this.#idleGraceMs)\n }\n\n #closeIdle(entry: PooledConnection): void {\n entry.idleTimer = null\n if (entry.leases.size > 0) return\n if (this.#entries.get(entry.key) !== entry) return\n\n this.#entries.delete(entry.key)\n entry.connection.dispose()\n this.#emit(entry, 'closed', {\n durationMs: Math.round(now() - entry.createdAt),\n reachedReady: entry.readyAt !== null,\n })\n }\n\n #retire(entry: PooledConnection): void {\n if (entry.idleTimer !== null) clearTimeout(entry.idleTimer)\n entry.idleTimer = null\n if (this.#entries.get(entry.key) === entry) this.#entries.delete(entry.key)\n entry.connection.dispose()\n this.#emit(entry, 'retired', {\n durationMs: Math.round(now() - entry.createdAt),\n reachedReady: entry.readyAt !== null,\n })\n }\n\n #reportUndispatchable(entry: PooledConnection, lease: ConnectionLease): void {\n const methods = Object.keys(lease.notificationHandlers).filter(\n (method) => !entry.notificationMethods.has(method),\n )\n if (methods.length === 0) return\n\n this.#emit(entry, 'handler_ignored', { methods })\n }\n\n #emit(\n entry: PooledConnection,\n kind: LspConnectionPoolEvent['kind'],\n extra: Omit<LspConnectionPoolEvent, 'kind' | 'key' | 'leaseCount' | 'status'> = {},\n ): void {\n this.#onEvent?.({\n key: entry.key,\n kind,\n leaseCount: entry.leases.size,\n status: entry.status,\n ...extra,\n })\n }\n}\n\n/** Snapshotted: a callback can release its own lease mid-iteration. */\nfunction leasesOf(entry: PooledConnection): readonly ConnectionLease[] {\n return Array.from(entry.leases)\n}\n\nfunction now(): number {\n return typeof performance === 'undefined' ? Date.now() : performance.now()\n}\n\nfunction initializationContract(options: LspConnectionOptions): ImmutableInitializationContract {\n return {\n capabilities: normalizeComparable(options.capabilities),\n clientInfo: normalizeComparable(options.clientInfo),\n initializationOptions: normalizeComparable(options.initializationOptions),\n rootUri: options.rootUri,\n }\n}\n\nfunction normalizeComparable(value: unknown): unknown {\n if (Array.isArray(value)) return value.map(normalizeComparable)\n if (!isRecord(value)) return value\n\n const normalized: Record<string, unknown> = {}\n const keys = Object.keys(value)\n .filter((key) => value[key] !== undefined)\n .sort()\n for (const key of keys) normalized[key] = normalizeComparable(value[key])\n return normalized\n}\n\nfunction structurallyEqual(left: unknown, right: unknown): boolean {\n if (Object.is(left, right)) return true\n if (Array.isArray(left) || Array.isArray(right)) return equalArrays(left, right)\n if (!isRecord(left) || !isRecord(right)) return false\n return equalRecords(left, right)\n}\n\nfunction equalArrays(left: unknown, right: unknown): boolean {\n if (!Array.isArray(left) || !Array.isArray(right)) return false\n if (left.length !== right.length) return false\n\n for (let index = 0; index < left.length; index += 1) {\n if (!structurallyEqual(left[index], right[index])) return false\n }\n return true\n}\n\nfunction equalRecords(left: Record<string, unknown>, right: Record<string, unknown>): boolean {\n const leftKeys = Object.keys(left)\n const rightKeys = Object.keys(right)\n if (leftKeys.length !== rightKeys.length) return false\n\n for (const key of leftKeys) {\n if (!(key in right)) return false\n if (!structurallyEqual(left[key], right[key])) return false\n }\n return true\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\n/**\n * A request has one answer, so the first borrower that handles the method gives it; the methods\n * are fixed by the first borrower, like the notification methods.\n */\nfunction requestDispatchers(\n entry: PooledConnection,\n initial: ServerRequestHandlers,\n): ServerRequestHandlers {\n const handlers: Record<string, LspServerRequestHandler<LspClient>> = {}\n for (const method of Object.keys(initial)) {\n handlers[method] = (client, params, message) => {\n const handler = leasesOf(entry).find((lease) => lease.serverRequestHandlers[method])\n ?.serverRequestHandlers[method]\n // An answer the server can mistake for an empty one is worse than an error it can report.\n if (!handler) throw new Error(`No editor on this connection answers ${method}`)\n return handler(client, params, message)\n }\n }\n return handlers\n}\n"],"mappings":";;;;;;;AAoBA,IAAM,wBAAwB;;;;;;AAkE9B,IAAa,oBAAb,MAA+B;CAC7B,2BAAoB,IAAI,IAA8B;CACtD;CACA;CAEA,YAAmB,UAAoC,CAAC,GAAG;EACzD,KAAK,eAAe,QAAQ,eAAe;EAC3C,KAAK,WAAW,QAAQ;CAC1B;;CAGA,SAAgB,KAAoC;EAClD,OAAO,EAAE,UAAU,SAAS,cAAc,KAAK,QAAQ,KAAK,SAAS,SAAS,EAAE;CAClF;CAEA,QACE,KACA,SACA,WACoB;EACpB,MAAM,WAAW,KAAK,SAAS,IAAI,GAAG;EACtC,IAAI,UAAU,KAAK,kBAAkB,UAAU,OAAO;EAEtD,MAAM,QAAQ,YAAY,KAAK,QAAQ,KAAK,OAAO;EACnD,IAAI,MAAM,cAAc,MAAM;GAC5B,aAAa,MAAM,SAAS;GAC5B,MAAM,YAAY;EACpB;EAEA,MAAM,QAAyB;GAC7B;GACA,sBAAsB,QAAQ,wBAAwB,CAAC;GACvD,uBAAuB,QAAQ,yBAAyB,CAAC;EAC3D;EACA,KAAK,sBAAsB,OAAO,KAAK;EACvC,MAAM,OAAO,IAAI,KAAK;EACtB,KAAK,MAAM,OAAO,WAAW,WAAW,SAAS;EACjD,KAAK,UAAU,OAAO,KAAK;EAE3B,OAAO;GACL,YAAY,MAAM;GAClB,eAAe,KAAK,SAAS,OAAO,KAAK;EAC3C;CACF;;CAGA,UAAuB;EACrB,KAAK,MAAM,SAAS,KAAK,SAAS,OAAO,GAAG;GAC1C,IAAI,MAAM,cAAc,MAAM,aAAa,MAAM,SAAS;GAC1D,MAAM,WAAW,QAAQ;EAC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,SAAS,aAAa,MAA+B,OAAyC;CAC5F,MAAM,WAAW,OAAO,KAAK,IAAI;CACjC,MAAM,YAAY,OAAO,KAAK,KAAK;CACnC,IAAI,SAAS,WAAW,UAAU,QAAQ,OAAO;CAEjD,KAAK,MAAM,OAAO,UAAU;EAC1B,IAAI,EAAE,OAAO,QAAQ,OAAO;EAC5B,IAAI,CAAC,kBAAkB,KAAK,MAAM,MAAM,IAAI,GAAG,OAAO;CACxD;CACA,OAAO;AACT;AAEA,SAAS,SAAS,OAAkD;CAClE,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC5E;;;;;AAMA,SAAS,mBACP,OACA,SACuB;CACvB,MAAM,WAA+D,CAAC;CACtE,KAAK,MAAM,UAAU,OAAO,KAAK,OAAO,GACtC,SAAS,WAAW,QAAQ,QAAQ,YAAY;EAC9C,MAAM,UAAU,SAAS,KAAK,CAAC,CAAC,MAAM,UAAU,MAAM,sBAAsB,OAAO,CAAC,EAChF,sBAAsB;EAE1B,IAAI,CAAC,SAAS,MAAM,IAAI,MAAM,wCAAwC,QAAQ;EAC9E,OAAO,QAAQ,QAAQ,QAAQ,OAAO;CACxC;CAEF,OAAO;AACT"}
|
package/dist/minimalEdits.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"minimalEdits.js","names":[],"sources":["../src/minimalEdits.ts"],"sourcesContent":["import type { TextEdit } from '@singapore-editor/core'\n\n/**\n * The longest replacement still worth re-diffing.\n *\n * Past this the comparison costs more than it saves: a reply that rewrites this much has left\n * almost no anchor, decoration or fold inside the span to preserve, and the diff itself becomes the\n * expensive part of formatting.\n */\nexport const REDIFF_LENGTH_LIMIT = 100_000\n\n/**\n * How far apart the two texts may be before the alignment is abandoned.\n *\n * One endpoint band per step is kept so the alignment can be walked back, so the memory held grows\n * with the square of this number. A reply differing by more than this is a rewrite rather than a\n * reformat, and is cheaper to apply whole.\n */\nconst REDIFF_STEP_LIMIT = 400\n\ntype LineRegion = {\n originalStart: number\n originalEnd: number\n replacementStart: number\n replacementEnd: number\n}\n\n/**\n * Splits a replacement into edits covering only what differs from the text it overwrites.\n *\n * A formatter answers with the whole document, or a whole line, even when three characters moved.\n * Applying that verbatim rewrites text that did not change, and every anchor, decoration, fold and\n * selection inside the rewritten span dies with it — so the reply is compared against the buffer\n * first and only the differences are handed on.\n *\n * `offset` is where `original` starts in the document, so the returned edits address the buffer.\n */\nexport function minimalReplacementEdits(\n original: string,\n replacement: string,\n offset: number,\n): TextEdit[] {\n if (original === replacement) return []\n if (Math.max(original.length, replacement.length) > REDIFF_LENGTH_LIMIT) {\n return [wholeReplacement(original, replacement, offset)]\n }\n\n const originalLines = splitAfterLineBreaks(original)\n const replacementLines = splitAfterLineBreaks(replacement)\n const regions = changedLineRegions(originalLines, replacementLines)\n if (!regions) return [wholeReplacement(original, replacement, offset)]\n\n const originalStarts = lineStartOffsets(originalLines)\n const replacementStarts = lineStartOffsets(replacementLines)\n\n const edits: TextEdit[] = []\n for (const region of regions) {\n const edit = narrowToDifference(\n original,\n originalStarts[region.originalStart] ?? 0,\n originalStarts[region.originalEnd] ?? original.length,\n replacement.slice(\n replacementStarts[region.replacementStart] ?? 0,\n replacementStarts[region.replacementEnd] ?? replacement.length,\n ),\n offset,\n )\n if (edit.from !== edit.to || edit.text.length > 0) edits.push(edit)\n }\n return edits\n}\n\nfunction wholeReplacement(original: string, replacement: string, offset: number): TextEdit {\n return { from: offset, text: replacement, to: offset + original.length }\n}\n\n/**\n * Shrinks one region to the characters inside it that differ.\n *\n * Line alignment hands back the whole line an indentation change sits in; dropping what the two\n * sides still share turns that into the handful of characters the formatter actually touched. A\n * boundary steps back off a surrogate pair, because half a code point is not something the rest of\n * the editor can anchor to.\n */\nfunction narrowToDifference(\n original: string,\n from: number,\n to: number,\n text: string,\n offset: number,\n): TextEdit {\n const shared = Math.min(to - from, text.length)\n\n let prefix = 0\n while (prefix < shared && original.charCodeAt(from + prefix) === text.charCodeAt(prefix)) {\n prefix += 1\n }\n if (prefix > 0 && isHighSurrogate(text.charCodeAt(prefix - 1))) prefix -= 1\n\n let suffix = 0\n while (\n suffix < shared - prefix &&\n original.charCodeAt(to - 1 - suffix) === text.charCodeAt(text.length - 1 - suffix)\n ) {\n suffix += 1\n }\n if (suffix > 0 && isLowSurrogate(text.charCodeAt(text.length - suffix))) suffix -= 1\n\n return {\n from: offset + from + prefix,\n text: text.slice(prefix, text.length - suffix),\n to: offset + to - suffix,\n }\n}\n\nfunction isHighSurrogate(code: number): boolean {\n return code >= 0xd800 && code <= 0xdbff\n}\n\nfunction isLowSurrogate(code: number): boolean {\n return code >= 0xdc00 && code <= 0xdfff\n}\n\n/** Lines keep their terminator, so concatenating them back gives the text they came from. */\nfunction splitAfterLineBreaks(text: string): string[] {\n const lines: string[] = []\n let start = 0\n for (let index = 0; index < text.length; index += 1) {\n if (text.charCodeAt(index) !== 10) continue\n\n lines.push(text.slice(start, index + 1))\n start = index + 1\n }\n lines.push(text.slice(start))\n return lines\n}\n\nfunction lineStartOffsets(lines: readonly string[]): number[] {\n const starts = [0]\n let offset = 0\n for (const line of lines) {\n offset += line.length\n starts.push(offset)\n }\n return starts\n}\n\n/**\n * Aligns two line sequences and returns the runs that do not correspond, or null when they lie\n * further apart than the step limit allows.\n *\n * The alignment is the shortest path that deletes original lines and inserts replacement ones,\n * taking equal lines for free; each step's furthest reach per diagonal is recorded so the path can\n * be walked back once the end is reached.\n *\n * Lines rather than characters, because a formatter's changes are line-shaped and aligning by line\n * costs a fraction of what aligning by character would; `narrowToDifference` recovers the\n * character-level precision afterwards, as a linear scan of one region.\n */\nfunction changedLineRegions(\n original: readonly string[],\n replacement: readonly string[],\n): LineRegion[] | null {\n const originalCount = original.length\n const replacementCount = replacement.length\n const stepLimit = Math.min(originalCount + replacementCount, REDIFF_STEP_LIMIT)\n // A diagonal is reachable only after as many steps as it is far from the origin, so the band of\n // live endpoints never widens past the step limit.\n const band = stepLimit + 1\n const endpoints = new Int32Array(2 * band + 1)\n const trace: Int32Array[] = []\n\n for (let step = 0; step <= stepLimit; step += 1) {\n trace.push(endpoints.slice(band - step, band + step + 1))\n\n for (let diagonal = -step; diagonal <= step; diagonal += 2) {\n const afterInsert = endpoints[band + diagonal + 1] ?? 0\n const afterDelete = endpoints[band + diagonal - 1] ?? 0\n const inserts = diagonal === -step || (diagonal !== step && afterDelete < afterInsert)\n let x = inserts ? afterInsert : afterDelete + 1\n let y = x - diagonal\n while (x < originalCount && y < replacementCount && original[x] === replacement[y]) {\n x += 1\n y += 1\n }\n endpoints[band + diagonal] = x\n\n if (x >= originalCount && y >= replacementCount) {\n return regionsFromTrace(trace, originalCount, replacementCount)\n }\n }\n }\n\n return null\n}\n\n/**\n * Walks the recorded alignment back from the end, collecting every step that was not a match.\n *\n * Consecutive non-matching steps belong to one region: they are separated only once a run of equal\n * lines has been walked back over, which moves both cursors away from the region being built.\n */\nfunction regionsFromTrace(\n trace: readonly Int32Array[],\n originalCount: number,\n replacementCount: number,\n): LineRegion[] {\n const regions: LineRegion[] = []\n let open: LineRegion | null = null\n let x = originalCount\n let y = replacementCount\n\n for (let step = trace.length - 1; step > 0; step -= 1) {\n const endpoints = trace[step]\n if (!endpoints) break\n\n const diagonal = x - y\n const afterInsert = endpoints[diagonal + 1 + step] ?? 0\n const afterDelete = endpoints[diagonal - 1 + step] ?? 0\n const inserts = diagonal === -step || (diagonal !== step && afterDelete < afterInsert)\n const previousDiagonal = inserts ? diagonal + 1 : diagonal - 1\n const previousX = inserts ? afterInsert : afterDelete\n const previousY = previousX - previousDiagonal\n\n while (x > previousX && y > previousY) {\n x -= 1\n y -= 1\n }\n\n if (open && open.originalStart === x && open.replacementStart === y) {\n open.originalStart = previousX\n open.replacementStart = previousY\n } else {\n open = {\n originalEnd: x,\n originalStart: previousX,\n replacementEnd: y,\n replacementStart: previousY,\n }\n regions.push(open)\n }\n\n x = previousX\n y = previousY\n }\n\n return regions.reverse()\n}\n"],"mappings":";;;;;;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UAAU,WAAW,IAAI,WAAW;EAC7D,MAAM,YAAY,UAAU,cAAc;EAC1C,MAAM,YAAY,YAAY;EAE9B,OAAO,IAAI,aAAa,IAAI,WAAW;GACrC,KAAK;GACL,KAAK;EACP;EAEA,IAAI,QAAQ,KAAK,kBAAkB,KAAK,KAAK,qBAAqB,GAAG;GACnE,KAAK,gBAAgB;GACrB,KAAK,mBAAmB;EAC1B,OAAO;GACL,OAAO;IACL,aAAa;IACb,eAAe;IACf,gBAAgB;IAChB,kBAAkB;GACpB;GACA,QAAQ,KAAK,IAAI;EACnB;EAEA,IAAI;EACJ,IAAI;CACN;CAEA,OAAO,QAAQ,QAAQ;AACzB"}
|
package/dist/paths.d.ts
CHANGED
|
@@ -3,4 +3,17 @@ export declare function sourcePathToFileName(path: string): string;
|
|
|
3
3
|
export declare function pathOrUriToDocumentUri(pathOrUri: string): lsp.DocumentUri;
|
|
4
4
|
export declare function fileNameToDocumentUri(fileName: string): lsp.DocumentUri;
|
|
5
5
|
export declare function documentUriToFileName(uri: string): string | null;
|
|
6
|
+
/**
|
|
7
|
+
* The URI of an absolute POSIX path, kept exact: a backslash is part of a name, never a separator.
|
|
8
|
+
* For a host whose document ids are paths in the file tree its language server reads.
|
|
9
|
+
*/
|
|
10
|
+
export declare function pathToFileUri(path: string): lsp.DocumentUri;
|
|
11
|
+
/**
|
|
12
|
+
* The exact path of a local `file:` URI: segments are decoded and nothing else is touched, so
|
|
13
|
+
* `..` stays for the file tree to resolve through its symlinks. Null for anything else, including
|
|
14
|
+
* a file on another host and a segment that would decode to a separator.
|
|
15
|
+
*/
|
|
16
|
+
export declare function fileUriToPath(uri: string): string | null;
|
|
17
|
+
/** Whether two URIs name one file, however each sender chose to escape its path. */
|
|
18
|
+
export declare function sameFileUri(left: lsp.DocumentUri, right: lsp.DocumentUri): boolean;
|
|
6
19
|
//# sourceMappingURL=paths.d.ts.map
|
package/dist/paths.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../src/paths.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,GAAG,MAAM,gCAAgC,CAAA;AAE1D,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAGzD;AAED,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,MAAM,GAAG,GAAG,CAAC,WAAW,CAMzE;AAED,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG,GAAG,CAAC,WAAW,CAGvE;AAED,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAQhE"}
|
|
1
|
+
{"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../src/paths.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,GAAG,MAAM,gCAAgC,CAAA;AAE1D,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAGzD;AAED,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,MAAM,GAAG,GAAG,CAAC,WAAW,CAMzE;AAED,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG,GAAG,CAAC,WAAW,CAGvE;AAED,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAQhE;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,CAAC,WAAW,CAE3D;AAKD;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAOxD;AAWD,oFAAoF;AACpF,wBAAgB,WAAW,CAAC,IAAI,EAAE,GAAG,CAAC,WAAW,EAAE,KAAK,EAAE,GAAG,CAAC,WAAW,GAAG,OAAO,CAKlF"}
|
package/dist/paths.js
CHANGED
|
@@ -21,17 +21,59 @@ function documentUriToFileName(uri) {
|
|
|
21
21
|
return null;
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* The URI of an absolute POSIX path, kept exact: a backslash is part of a name, never a separator.
|
|
26
|
+
* For a host whose document ids are paths in the file tree its language server reads.
|
|
27
|
+
*/
|
|
28
|
+
function pathToFileUri(path) {
|
|
29
|
+
return `file://${encodePathname(path)}`;
|
|
30
|
+
}
|
|
31
|
+
/** `file:`, an optional `//authority`, then an absolute path; a query or fragment is dropped. */
|
|
32
|
+
var FILE_URI = /^file:(?:\/\/([^/?#]*))?(\/[^?#]*)/i;
|
|
33
|
+
/**
|
|
34
|
+
* The exact path of a local `file:` URI: segments are decoded and nothing else is touched, so
|
|
35
|
+
* `..` stays for the file tree to resolve through its symlinks. Null for anything else, including
|
|
36
|
+
* a file on another host and a segment that would decode to a separator.
|
|
37
|
+
*/
|
|
38
|
+
function fileUriToPath(uri) {
|
|
39
|
+
const [, authority, encoded] = FILE_URI.exec(uri) ?? [];
|
|
40
|
+
if (encoded === void 0 || authority) return null;
|
|
41
|
+
const segments = encoded.split("/").map(decodeSegment);
|
|
42
|
+
return segments.includes(null) ? null : segments.join("/");
|
|
43
|
+
}
|
|
44
|
+
function decodeSegment(segment) {
|
|
45
|
+
try {
|
|
46
|
+
const decoded = decodeURIComponent(segment);
|
|
47
|
+
return decoded.includes("/") || decoded.includes("\0") ? null : decoded;
|
|
48
|
+
} catch {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/** Whether two URIs name one file, however each sender chose to escape its path. */
|
|
53
|
+
function sameFileUri(left, right) {
|
|
54
|
+
if (left === right) return true;
|
|
55
|
+
const path = fileUriToPath(left);
|
|
56
|
+
return path !== null && path === fileUriToPath(right);
|
|
57
|
+
}
|
|
24
58
|
function normalizeFileNamePath(path) {
|
|
25
59
|
const normalized = path.replaceAll("\\", "/").replace(/^\/+/, "");
|
|
26
60
|
if (!normalized) return "/";
|
|
27
61
|
return `/${normalized}`;
|
|
28
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* The form `vscode-uri` produces, which Node language servers send back: everything but RFC 3986
|
|
65
|
+
* unreserved characters is escaped. A server URI is matched to an open document as a string, so a
|
|
66
|
+
* path such as `app/(shop)/page.tsx` has to leave here spelled the way it will return.
|
|
67
|
+
*/
|
|
29
68
|
function encodePathname(pathname) {
|
|
30
|
-
return pathname.split("/").map((part
|
|
69
|
+
return pathname.split("/").map((part) => encodeURIComponent(part).replace(/[!'()*]/g, percentEncode)).join("/");
|
|
70
|
+
}
|
|
71
|
+
function percentEncode(character) {
|
|
72
|
+
return `%${character.charCodeAt(0).toString(16).toUpperCase()}`;
|
|
31
73
|
}
|
|
32
74
|
function hasUriScheme(value) {
|
|
33
75
|
return /^[A-Za-z][A-Za-z0-9+.-]*:/.test(value);
|
|
34
76
|
}
|
|
35
|
-
export { documentUriToFileName, fileNameToDocumentUri, pathOrUriToDocumentUri, sourcePathToFileName };
|
|
77
|
+
export { documentUriToFileName, fileNameToDocumentUri, fileUriToPath, pathOrUriToDocumentUri, pathToFileUri, sameFileUri, sourcePathToFileName };
|
|
36
78
|
|
|
37
79
|
//# sourceMappingURL=paths.js.map
|
package/dist/paths.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paths.js","names":[],"sources":["../src/paths.ts"],"
|
|
1
|
+
{"version":3,"file":"paths.js","names":[],"sources":["../src/paths.ts"],"mappings":";AAEA,SAAgB,qBAAqB,MAAsB;CACzD,IAAI,aAAa,IAAI,GAAG,OAAO,sBAAsB,IAAI,KAAK,sBAAsB,IAAI;CACxF,OAAO,sBAAsB,IAAI;AACnC;AAEA,SAAgB,uBAAuB,WAAoC;CACzE,IAAI,CAAC,aAAa,SAAS,GAAG,OAAO,sBAAsB,qBAAqB,SAAS,CAAC;CAE1F,MAAM,WAAW,sBAAsB,SAAS;CAChD,IAAI,CAAC,UAAU,OAAO;CACtB,OAAO,sBAAsB,QAAQ;AACvC;AAEA,SAAgB,sBAAsB,UAAmC;CAEv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ACb;AAEA,SAAS,cAAc,WAA2B;CAChD,OAAO,IAAI,UAAU,WAAW,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,YAAY;AAC9D;AAEA,SAAS,aAAa,OAAwB;CAC5C,OAAO,4BAA4B,KAAK,KAAK;AAC/C"}
|
package/dist/plugin.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import type * as lsp from 'vscode-languageserver-protocol';
|
|
|
6
6
|
import { type LanguageServerCompletionEditFeature } from './completion';
|
|
7
7
|
import { type CompletionKeyCommand, type SignatureHelpKeyCommand } from './keyCommands';
|
|
8
8
|
import { type LanguageServerSemanticTokensOptions } from './semanticTokens';
|
|
9
|
-
import type { LspConnectionProvider, LspConnectionTransportFactory } from './lspConnection';
|
|
9
|
+
import type { LspConnectionProvider, LspConnectionTransportFactory, LspReconnectOptions } from './lspConnection';
|
|
10
10
|
import type { DiagnosticMarkerDirection, LanguageServerNavigationCommand } from './pluginTypes';
|
|
11
11
|
import type { LanguageServerConnectionContext, LanguageServerDefinitionTarget, LanguageServerDiagnosticActions, LanguageServerDiagnosticMarkerClaim, LanguageServerDiagnosticMarkerEvent, LanguageServerDiagnosticSummary, LanguageServerDocumentSyncOptions, LanguageServerNavigationOptions, LanguageServerPlugin, LanguageServerLaneHostOptions, LanguageServerPluginOptions, LanguageServerRenamePrompt, LanguageServerSetPluginOptions, LanguageServerReferencesResult, LanguageServerStatus } from './types';
|
|
12
12
|
export type { LanguageServerConnectionContext } from './types';
|
|
@@ -44,6 +44,11 @@ export type LanguageServerAdapterPluginOptions = LanguageServerLaneHostOptions &
|
|
|
44
44
|
/** See LanguageServerPluginOptions.serverRequestHandlers. */
|
|
45
45
|
readonly serverRequestHandlers?: Readonly<Record<string, LspServerRequestHandler<LspClient>>>;
|
|
46
46
|
createTransport(): ReturnType<LspConnectionTransportFactory>;
|
|
47
|
+
/**
|
|
48
|
+
* Calls `createTransport` again after the server goes away on its own, so a factory that starts
|
|
49
|
+
* a server process restarts it. Off unless given.
|
|
50
|
+
*/
|
|
51
|
+
readonly reconnect?: LspReconnectOptions;
|
|
47
52
|
/** Borrows the connection instead of constructing one per view. See LspConnectionProvider. */
|
|
48
53
|
readonly connectionProvider?: LspConnectionProvider;
|
|
49
54
|
readonly documentSync?: LanguageServerDocumentSyncOptions;
|
package/dist/plugin.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mCAAmC,EAAE,MAAM,SAAS,CAAA;AAClE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AACpE,OAAO,KAAK,EAEV,qBAAqB,EAErB,gBAAgB,EAOjB,MAAM,mCAAmC,CAAA;AAC1C,OAAO,KAAK,EACV,SAAS,EACT,sBAAsB,EACtB,uBAAuB,EAExB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,KAAK,KAAK,GAAG,MAAM,gCAAgC,CAAA;AAE1D,OAAO,EAGL,KAAK,mCAAmC,EACzC,MAAM,cAAc,CAAA;AAUrB,OAAO,EAGL,KAAK,oBAAoB,EACzB,KAAK,uBAAuB,EAC7B,MAAM,eAAe,CAAA;AAgBtB,OAAO,EAGL,KAAK,mCAAmC,EAEzC,MAAM,kBAAkB,CAAA;AAWzB,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mCAAmC,EAAE,MAAM,SAAS,CAAA;AAClE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AACpE,OAAO,KAAK,EAEV,qBAAqB,EAErB,gBAAgB,EAOjB,MAAM,mCAAmC,CAAA;AAC1C,OAAO,KAAK,EACV,SAAS,EACT,sBAAsB,EACtB,uBAAuB,EAExB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,KAAK,KAAK,GAA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AK,EAAE,mCAAmC,KACvC,mCAAmC,CAAA;IACxC,QAAQ,CAAC,kBAAkB,CAAC,EAAE,MAAM,IAAI,CAAA;IACxC,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI,CAAA;IACpF,QAAQ,CAAC,qBAAqB,CAAC,EAAE,CAAC,MAAM,EAAE,8BAA8B,KAAK,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,CAAA;IAChG,QAAQ,CAAC,gBAAgB,CAAC,EAAE,CAC1B,MAAM,EAAE,8BAA8B,EACtC,OAAO,CAAC,EAAE,+BAA+B,KACtC,IAAI,GAAG,OAAO,CAAA;IACnB,QAAQ,CAAC,gBAAgB,CAAC,EAAE,CAAC,MAAM,EAAE,8BAA8B,KAAK,IAAI,GAAG,OAAO,CAAA;IACtF,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAA;CAC5C,CAAA;AA4CD,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,2BAA2B,GACnC,oBAAoB,CAAA;AACvB,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,mCAAmC,GAC3C,oBAAoB,CAAA;AAqBvB,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,8BAA8B,GACtC,oBAAoB,CAEtB;AAED,wBAAgB,iCAAiC,CAC/C,OAAO,EAAE,kCAAkC,GAC1C,oBAAoB,CAEtB"}
|
package/dist/plugin.js
CHANGED
|
@@ -735,6 +735,7 @@ function resolvedLaneFromAdapterOptions(options) {
|
|
|
735
735
|
notificationHandlers: options.notificationHandlers,
|
|
736
736
|
serverRequestHandlers: options.serverRequestHandlers,
|
|
737
737
|
createTransport: options.createTransport,
|
|
738
|
+
reconnect: options.reconnect,
|
|
738
739
|
connectionProvider: options.connectionProvider,
|
|
739
740
|
onApplyWorkspaceEdit: options.onApplyWorkspaceEdit,
|
|
740
741
|
onConnectionCreated: options.onConnectionCreated,
|