@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
@@ -1,24 +1,25 @@
1
1
  import { projectDiagnosticsInSnapshot } from "./diagnosticProjection.js";
2
2
  import { pathOrUriToDocumentUri } from "./paths.js";
3
3
  import { viewDocumentSnapshot } from "./viewDocumentSnapshot.js";
4
- import "@singapore-editor/core/document";
5
- import { recordLspPerformanceDiagnostic } from "@singapore-editor/lsp";
6
- //#region src/documentSync.ts
4
+ import { observeLanguageServerSource, retainLanguageServerSource } from "./retainedSource.js";
5
+ // src/documentSync.ts
7
6
  var DocumentSync = class {
8
7
  workspace;
9
8
  presenter;
10
9
  options;
11
- attachment = null;
10
+ binding = null;
12
11
  document = null;
13
12
  diagnosticItems = [];
14
- logicalRevisionScope;
15
13
  pendingUriProjection = null;
16
- syncPoint = null;
14
+ unsubscribe;
17
15
  constructor(workspace, presenter, options) {
18
16
  this.workspace = workspace;
19
17
  this.presenter = presenter;
20
18
  this.options = options;
21
- this.logicalRevisionScope = options.logicalRevisionScope;
19
+ this.unsubscribe = observeLanguageServerSource(workspace, {
20
+ deliver: this.adoptPublication,
21
+ onError: options.onError
22
+ });
22
23
  }
23
24
  get activeDocument() {
24
25
  return this.document;
@@ -28,78 +29,59 @@ var DocumentSync = class {
28
29
  }
29
30
  shouldSync(kind, snapshot) {
30
31
  if (kind === "document" || kind === "content" || kind === "clear") return true;
31
- if (!this.document) return false;
32
- return !sameSyncPoint(this.syncPoint, snapshot.documentSyncPoint);
33
- }
34
- sync(snapshot, change) {
35
- const projectedUri = this.projectedDocumentUri(snapshot);
36
- const descriptor = documentDescriptor(snapshot, this.options, projectedUri);
37
- if (!descriptor) {
38
- this.detachDocument();
32
+ const descriptor = this.descriptor(snapshot);
33
+ return descriptor?.uri !== this.binding?.uri || descriptor?.languageId !== this.binding?.languageId;
34
+ }
35
+ async sync(snapshot) {
36
+ const descriptor = this.descriptor(snapshot);
37
+ const source = this.options.getSourceOwner();
38
+ const connection = this.options.getConnection();
39
+ if (!descriptor || !source || !connection) {
40
+ this.detach();
39
41
  return;
40
42
  }
41
- this.openOrUpdateDocument(descriptor, change, snapshot);
43
+ await this.bind(source, connection, descriptor)?.lease.request();
42
44
  }
43
45
  close() {
44
46
  this.pendingUriProjection = null;
45
- this.detachDocument();
47
+ this.detach();
48
+ }
49
+ dispose() {
50
+ this.unsubscribe();
51
+ this.close();
46
52
  }
47
53
  transitionDocumentUri(snapshot, transition) {
48
- if (!this.matchesTransitionSource(snapshot, transition)) return false;
49
- const descriptor = documentDescriptor(snapshot, this.options, transition.toUri, transition.textSnapshot);
54
+ const active = this.document;
55
+ const binding = this.binding;
56
+ if (!active || !binding || active.uri !== transition.fromUri) return false;
57
+ if (active.sourceSegment !== transition.previousSyncPoint.segment) return false;
58
+ if (active.sourceRevision > transition.previousSyncPoint.revision) return false;
59
+ if (transition.previousSyncPoint.revision !== transition.syncPoint.revision || transition.previousSyncPoint.textVersion !== transition.syncPoint.textVersion) return false;
60
+ if (transition.previousSyncPoint.segment === transition.syncPoint.segment) return false;
61
+ const descriptor = documentDescriptor(snapshot, this.options, transition.toUri);
50
62
  if (!descriptor) {
51
- this.detachDocument();
52
- this.pendingUriProjection = pendingUriProjection(transition);
63
+ this.close();
53
64
  return true;
54
65
  }
55
- this.transitionDocument(descriptor, transition.syncPoint);
56
- return true;
57
- }
58
- detachDocument() {
59
- const active = this.document;
60
- const attachment = this.attachment;
61
- this.attachment = null;
62
- this.document = null;
63
- this.diagnosticItems = [];
64
- this.syncPoint = null;
65
- this.options.onDocumentClosed();
66
- if (!active) return;
67
- this.presenter.clear();
68
- if (attachment) this.workspace.closeDocument(attachment);
69
- this.presenter.publishSummary(active.uri, active.lspVersion, [], "reset");
70
- }
71
- matchesTransitionSource(snapshot, transition) {
72
- const active = this.document;
73
- const point = this.syncPoint;
74
- if (!active || !this.attachment || !point) return false;
75
- if (active.uri !== transition.fromUri) return false;
76
- if (active.textSnapshot !== transition.textSnapshot) return false;
77
- if (snapshot.textSnapshot !== transition.textSnapshot) return false;
78
- if (point.revision !== transition.syncPoint.revision) return false;
79
- if (point.textVersion !== transition.syncPoint.textVersion) return false;
80
- return point.segment !== transition.syncPoint.segment;
81
- }
82
- projectedDocumentUri(snapshot) {
83
- const projection = this.pendingUriProjection;
84
- if (!projection) return void 0;
85
- if (snapshot.documentSyncPoint.segment !== projection.segment) {
86
- this.pendingUriProjection = null;
87
- return;
88
- }
89
- const uri = documentUri(snapshot, this.options);
90
- if (uri === null) {
91
- this.pendingUriProjection = null;
92
- return;
66
+ this.pendingUriProjection = {
67
+ fromUri: documentUri(snapshot, this.options) ?? transition.fromUri,
68
+ toUri: transition.toUri,
69
+ segment: transition.syncPoint.segment,
70
+ previousSegment: transition.previousSyncPoint.segment
71
+ };
72
+ const source = this.options.getSourceOwner();
73
+ const connection = this.options.getConnection();
74
+ if (!source || !connection) {
75
+ this.detach();
76
+ return true;
93
77
  }
94
- if (uri === projection.fromUri) return projection.toUri;
95
- this.pendingUriProjection = null;
78
+ this.bind(source, connection, descriptor)?.lease.request().catch(this.options.onError);
79
+ return true;
96
80
  }
97
81
  publishDiagnostics(params) {
98
82
  const diagnostics = publishDiagnosticsParams(params);
99
- if (!diagnostics) return;
100
83
  const active = this.document;
101
- if (!active) return;
102
- if (diagnostics.uri !== active.uri) return;
84
+ if (!diagnostics || !active || diagnostics.uri !== active.uri) return;
103
85
  if (diagnostics.version !== null && diagnostics.version !== active.lspVersion) return;
104
86
  this.replaceDiagnostics(active, diagnostics.version, diagnostics.diagnostics);
105
87
  }
@@ -112,164 +94,85 @@ var DocumentSync = class {
112
94
  const active = this.document;
113
95
  this.diagnosticItems = [];
114
96
  this.presenter.clear();
115
- if (!active) return;
116
- this.presenter.publishSummary(active.uri, active.lspVersion, [], "reset");
117
- }
118
- openOrUpdateDocument(descriptor, change, snapshot) {
119
- const active = this.document;
120
- if (!active) {
121
- this.openDocument(descriptor, snapshot.documentSyncPoint);
122
- return;
123
- }
124
- if (active.uri !== descriptor.uri) {
125
- this.replaceOrTransitionDocument(descriptor, snapshot.documentSyncPoint);
126
- return;
127
- }
128
- if (active.languageId !== descriptor.languageId) {
129
- this.openDocument(descriptor, snapshot.documentSyncPoint);
130
- return;
131
- }
132
- if (sameSyncPoint(this.syncPoint, snapshot.documentSyncPoint)) return;
133
- this.updateDocument(descriptor, change, snapshot);
97
+ if (active) this.presenter.publishSummary(active.uri, active.lspVersion, [], "reset");
134
98
  }
135
- replaceDiagnostics(active, version, diagnostics) {
136
- this.diagnosticItems = diagnostics;
137
- this.presenter.render(active, diagnostics);
138
- this.presenter.publishSummary(active.uri, version, diagnostics, "result");
99
+ descriptor(snapshot) {
100
+ const projection = this.pendingUriProjection;
101
+ const uri = documentUri(snapshot, this.options);
102
+ if (projection && uri === projection.fromUri && (snapshot.documentSyncPoint.segment === projection.segment || snapshot.documentSyncPoint.segment === projection.previousSegment)) return documentDescriptor(snapshot, this.options, projection.toUri);
103
+ this.pendingUriProjection = null;
104
+ return documentDescriptor(snapshot, this.options);
139
105
  }
140
- openDocument(descriptor, syncPoint) {
141
- this.close();
142
- const result = this.workspace.openDocumentSnapshot({
106
+ bind(source, connection, descriptor) {
107
+ const previous = this.binding;
108
+ if (previous && sameOwner(previous.source, source) && previous.connection === connection && previous.uri === descriptor.uri && previous.languageId === descriptor.languageId) return previous;
109
+ this.detach();
110
+ const lease = retainLanguageServerSource({
111
+ ...source,
112
+ workspace: this.workspace,
143
113
  uri: descriptor.uri,
144
114
  languageId: descriptor.languageId,
145
- textSnapshot: descriptor.textSnapshot,
146
- lineStarts: descriptor.lineStarts,
147
- sourceRevision: syncPoint.revision,
148
- sourceSegment: syncPoint.segment,
149
- onDocumentTransition: (transition) => this.adoptDocumentTransition(transition)
115
+ logicalRevisionScope: this.options.logicalRevisionScope,
116
+ connection
150
117
  });
151
- this.attachment = result.attachment;
152
- this.document = activeDocument(descriptor, result.document.version);
153
- this.syncPoint = syncPoint;
154
- }
155
- replaceOrTransitionDocument(descriptor, syncPoint) {
156
- if (!isSharedUriTransition(this.document, this.syncPoint, descriptor, syncPoint)) {
157
- this.openDocument(descriptor, syncPoint);
158
- return;
159
- }
160
- this.transitionDocument(descriptor, syncPoint);
161
- }
162
- transitionDocument(descriptor, syncPoint) {
163
- const attachment = this.attachment;
164
- if (!attachment) throw new Error("An active LSP document must retain its workspace attachment.");
165
- const result = this.workspace.transitionDocumentUri(attachment, {
118
+ this.binding = lease ? {
119
+ source,
120
+ connection,
166
121
  uri: descriptor.uri,
167
122
  languageId: descriptor.languageId,
168
- textSnapshot: descriptor.textSnapshot,
169
- lineStarts: descriptor.lineStarts,
170
- sourceRevision: syncPoint.revision,
171
- sourceSegment: syncPoint.segment,
172
- sourceTextVersion: syncPoint.textVersion
173
- });
174
- this.document = activeDocument(descriptor, result.document.version);
175
- this.syncPoint = syncPoint;
176
- }
177
- updateDocument(descriptor, change, snapshot) {
178
- const active = this.document;
179
- const diagnostics = projectDiagnosticsInSnapshot(this.diagnosticItems, {
180
- previousDocument: active ?? descriptor,
181
- nextDocument: descriptor,
182
- change
183
- });
184
- const changes = changesSinceLastSync(snapshot, this.syncPoint, this.logicalRevisionScope, change, active?.textSnapshot ?? descriptor.textSnapshot, descriptor.textSnapshot);
185
- recordLspPerformanceDiagnostic("lsp.documentSync.editChain", {
186
- chained: changes.edits === null ? "null" : changes.edits.length,
187
- logicalRevisionCount: changes.logicalRevisionCount,
188
- activeTextVersion: active?.textVersion ?? -1,
189
- snapshotTextVersion: snapshot.textVersion,
190
- changeEditCount: change?.edits.length ?? -1
191
- });
192
- const document = this.synchronizeWorkspaceDocument(descriptor, changes);
193
- this.document = activeDocument(descriptor, document.version);
194
- this.syncPoint = changes.syncPointAfter;
195
- if (diagnostics === this.diagnosticItems) return;
196
- this.diagnosticItems = diagnostics;
197
- this.presenter.render(descriptor, diagnostics);
198
- }
199
- synchronizeWorkspaceDocument(descriptor, changes) {
200
- const source = {
201
- textSnapshot: descriptor.textSnapshot,
202
- lineStarts: descriptor.lineStarts,
203
- sourceRevision: changes.syncPointAfter.revision,
204
- sourceSegment: changes.syncPointAfter.segment
205
- };
206
- if (changes.logicalRevisionCount === 0) return this.workspace.adoptUnchangedDocumentSource(descriptor.uri, source);
207
- return this.workspace.updateDocumentSnapshot(descriptor.uri, {
208
- ...source,
209
- edits: changes.edits,
210
- logicalRevisionCount: changes.logicalRevisionCount
211
- });
123
+ lease
124
+ } : null;
125
+ return this.binding;
126
+ }
127
+ detach() {
128
+ const binding = this.binding;
129
+ this.binding = null;
130
+ try {
131
+ binding?.lease.dispose();
132
+ } finally {
133
+ this.clearDocument();
134
+ }
212
135
  }
213
- adoptDocumentTransition(transition) {
136
+ clearDocument() {
214
137
  const active = this.document;
215
- if (!active) return;
138
+ this.document = null;
216
139
  this.diagnosticItems = [];
140
+ this.options.onDocumentClosed();
217
141
  this.presenter.clear();
218
- this.presenter.publishSummary(active.uri, active.lspVersion, [], "reset");
219
- this.pendingUriProjection = {
220
- fromUri: active.uri,
221
- toUri: transition.document.uri,
222
- segment: transition.sourceSegment
223
- };
224
- this.document = activeDocumentForTransition(active, transition);
225
- this.syncPoint = {
226
- revision: transition.sourceRevision,
227
- segment: transition.sourceSegment,
228
- textVersion: transition.sourceTextVersion
142
+ if (active) this.presenter.publishSummary(active.uri, active.lspVersion, [], "reset");
143
+ }
144
+ adoptPublication = (publication) => {
145
+ if (publication.runtimeSessionId !== this.binding?.lease.runtimeSessionId) return;
146
+ const next = publication.document;
147
+ if (!next) {
148
+ this.clearDocument();
149
+ return;
150
+ }
151
+ const previous = this.document;
152
+ if (previous?.sourceRevision === next.sourceRevision && previous.sourceSegment === next.sourceSegment && previous.lspVersion === next.version) return;
153
+ if (previous && previous.textSnapshot !== next.textSnapshot) this.diagnosticItems = projectDiagnosticsInSnapshot(this.diagnosticItems, {
154
+ previousDocument: previous,
155
+ nextDocument: next,
156
+ change: publication.edits ? { edits: publication.edits } : null
157
+ });
158
+ this.document = {
159
+ ...next,
160
+ textVersion: publication.point?.textVersion ?? 0,
161
+ lspVersion: next.version
229
162
  };
163
+ this.presenter.render(this.document, this.diagnosticItems);
164
+ this.options.onDocumentChanged();
165
+ };
166
+ replaceDiagnostics(active, version, diagnostics) {
167
+ this.diagnosticItems = diagnostics;
168
+ this.presenter.render(active, diagnostics);
169
+ this.presenter.publishSummary(active.uri, version, diagnostics, "result");
230
170
  }
231
171
  };
232
- function pendingUriProjection(transition) {
233
- return {
234
- fromUri: transition.fromUri,
235
- toUri: transition.toUri,
236
- segment: transition.syncPoint.segment
237
- };
238
- }
239
- function changesSinceLastSync(snapshot, point, scope, change, previousTextSnapshot, nextTextSnapshot) {
240
- if (!point) return fallbackSyncChanges(snapshot, null, change, scope, previousTextSnapshot, nextTextSnapshot);
241
- const changes = snapshot.changesSinceDocumentSyncPoint(point, scope);
242
- if (changes) return {
243
- edits: changes.edits,
244
- logicalRevisionCount: changes.logicalRevisionCount,
245
- syncPointAfter: changes.syncPointAfter
246
- };
247
- return fallbackSyncChanges(snapshot, point, change, scope, previousTextSnapshot, nextTextSnapshot);
248
- }
249
- function fallbackSyncChanges(snapshot, point, change, scope, previousTextSnapshot, nextTextSnapshot) {
250
- const nextPoint = snapshot.documentSyncPoint;
251
- return {
252
- edits: null,
253
- logicalRevisionCount: fallbackLogicalRevisionCount(change, scope, previousTextSnapshot !== nextTextSnapshot || point === null || point.textVersion !== nextPoint.textVersion, point, nextPoint),
254
- syncPointAfter: nextPoint
255
- };
256
- }
257
- function fallbackLogicalRevisionCount(change, scope, textChanged, point, nextPoint) {
258
- if (change?.logicalRevisionScope === scope) return change.logicalRevisionCount;
259
- if (!textChanged) return 0;
260
- if (!point) return 1;
261
- return Math.max(1, nextPoint.textVersion - point.textVersion);
262
- }
263
- function sameSyncPoint(left, right) {
264
- if (!left) return false;
265
- return left.revision === right.revision && left.segment === right.segment && left.textVersion === right.textVersion;
266
- }
267
- function isSharedUriTransition(active, currentPoint, descriptor, nextPoint) {
268
- if (!active || !currentPoint) return false;
269
- if (active.textSnapshot !== descriptor.textSnapshot) return false;
270
- if (currentPoint.revision !== nextPoint.revision) return false;
271
- if (currentPoint.textVersion !== nextPoint.textVersion) return false;
272
- return currentPoint.segment !== nextPoint.segment;
172
+ function sameOwner(left, right) {
173
+ if ("buffer" in left && "buffer" in right) return left.buffer === right.buffer;
174
+ if ("contributions" in left && "contributions" in right) return left.contributions === right.contributions;
175
+ return false;
273
176
  }
274
177
  function activeDocument(descriptor, lspVersion) {
275
178
  return {
@@ -278,26 +181,16 @@ function activeDocument(descriptor, lspVersion) {
278
181
  textSnapshot: descriptor.textSnapshot,
279
182
  lineStarts: descriptor.lineStarts,
280
183
  textVersion: descriptor.textVersion,
281
- lspVersion
282
- };
283
- }
284
- function activeDocumentForTransition(active, transition) {
285
- const document = transition.document;
286
- return {
287
- uri: document.uri,
288
- languageId: document.languageId,
289
- textSnapshot: document.textSnapshot,
290
- lineStarts: document.lineStarts,
291
- textVersion: active.textVersion,
292
- lspVersion: document.version
184
+ lspVersion,
185
+ sourceRevision: descriptor.sourceRevision,
186
+ sourceSegment: descriptor.sourceSegment
293
187
  };
294
188
  }
295
189
  function documentUri(snapshot, options) {
296
- if (!snapshot.documentId) return null;
297
190
  if (options.uriForDocument) return options.uriForDocument(snapshot);
298
- return pathOrUriToDocumentUri(snapshot.documentId);
191
+ return snapshot.documentId ? pathOrUriToDocumentUri(snapshot.documentId) : null;
299
192
  }
300
- function documentDescriptor(snapshot, options, projectedUri, projectedTextSnapshot) {
193
+ function documentDescriptor(snapshot, options, projectedUri) {
301
194
  if (!snapshot.languageId) return null;
302
195
  if (options.shouldSyncLanguageId?.(snapshot.languageId, snapshot) === false) return null;
303
196
  const resolvedUri = documentUri(snapshot, options);
@@ -308,9 +201,11 @@ function documentDescriptor(snapshot, options, projectedUri, projectedTextSnapsh
308
201
  return {
309
202
  uri,
310
203
  languageId: options.languageIdForDocument?.(snapshot.languageId, uri) ?? snapshot.languageId,
311
- textSnapshot: projectedTextSnapshot ?? document.textSnapshot,
204
+ textSnapshot: document.textSnapshot,
312
205
  lineStarts: document.lineStarts,
313
- textVersion: snapshot.textVersion
206
+ textVersion: snapshot.textVersion,
207
+ sourceRevision: snapshot.documentSyncPoint.revision,
208
+ sourceSegment: snapshot.documentSyncPoint.segment
314
209
  };
315
210
  }
316
211
  function activeDocumentForSnapshot(snapshot, options) {
@@ -328,7 +223,6 @@ function publishDiagnosticsParams(params) {
328
223
  };
329
224
  }
330
225
  var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
331
- //#endregion
332
226
  export { DocumentSync, activeDocumentForSnapshot };
333
227
 
334
228
  //# sourceMappingURL=documentSync.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"documentSync.js","names":[],"sources":["../src/documentSync.ts"],"sourcesContent":["import type { LanguageServerDocumentSnapshot } from './types'\nimport {\n type DocumentLogicalRevisionScope,\n type DocumentSyncPoint,\n type DocumentSyncSegment,\n type TextEdit,\n} from '@singapore-editor/core/document'\nimport type {\n EditorContributionChange,\n EditorViewContributionUpdateKind,\n} from '@singapore-editor/core/extensions'\nimport {\n recordLspPerformanceDiagnostic,\n type LspDocumentTransitionNotification,\n type LspTextDocumentSnapshot,\n type LspTextSnapshot,\n type LspWorkspaceDocumentAttachment,\n type LspWorkspace,\n} from '@singapore-editor/lsp'\nimport type * as lsp from 'vscode-languageserver-protocol'\n\nimport { projectDiagnosticsInSnapshot } from './diagnosticProjection'\nimport type { LanguageServerDocumentUriTransition } from './documentSyncController'\nimport { pathOrUriToDocumentUri } from './paths'\nimport type { ActiveDocument, DocumentDescriptor } from './pluginTypes'\nimport type { LanguageServerDocumentSyncOptions } from './types'\nimport { viewDocumentSnapshot } from './viewDocumentSnapshot'\n\n/** `result` came from the server; `reset` is the client emptying the list itself. */\nexport type DocumentSyncSummaryKind = 'result' | 'reset'\n\nexport type DocumentSyncDiagnosticsPresenter = {\n clear(): void\n render(document: LspTextDocumentSnapshot, diagnostics: readonly lsp.Diagnostic[]): void\n publishSummary(\n uri: lsp.DocumentUri,\n version: number | null,\n diagnostics: readonly lsp.Diagnostic[],\n kind: DocumentSyncSummaryKind,\n ): void\n}\n\nexport type DocumentSyncOptions = LanguageServerDocumentSyncOptions & {\n readonly logicalRevisionScope: DocumentLogicalRevisionScope\n onDocumentClosed(): void\n}\n\nexport class DocumentSync {\n private attachment: LspWorkspaceDocumentAttachment | null = null\n private document: ActiveDocument | null = null\n private diagnosticItems: readonly lsp.Diagnostic[] = []\n private readonly logicalRevisionScope: DocumentLogicalRevisionScope\n private pendingUriProjection: PendingUriProjection | null = null\n private syncPoint: DocumentSyncPoint | null = null\n\n public constructor(\n private readonly workspace: LspWorkspace,\n private readonly presenter: DocumentSyncDiagnosticsPresenter,\n private readonly options: DocumentSyncOptions,\n ) {\n this.logicalRevisionScope = options.logicalRevisionScope\n }\n\n public get activeDocument(): ActiveDocument | null {\n return this.document\n }\n\n public get diagnostics(): readonly lsp.Diagnostic[] {\n return this.diagnosticItems\n }\n\n public shouldSync(\n kind: EditorViewContributionUpdateKind,\n snapshot: LanguageServerDocumentSnapshot,\n ): boolean {\n if (kind === 'document' || kind === 'content' || kind === 'clear') return true\n if (!this.document) return false\n return !sameSyncPoint(this.syncPoint, snapshot.documentSyncPoint)\n }\n\n public sync(\n snapshot: LanguageServerDocumentSnapshot,\n change: EditorContributionChange | null,\n ): void {\n const projectedUri = this.projectedDocumentUri(snapshot)\n const descriptor = documentDescriptor(snapshot, this.options, projectedUri)\n if (!descriptor) {\n this.detachDocument()\n return\n }\n\n this.openOrUpdateDocument(descriptor, change, snapshot)\n }\n\n public close(): void {\n this.pendingUriProjection = null\n this.detachDocument()\n }\n\n public transitionDocumentUri(\n snapshot: LanguageServerDocumentSnapshot,\n transition: LanguageServerDocumentUriTransition,\n ): boolean {\n if (!this.matchesTransitionSource(snapshot, transition)) return false\n\n const descriptor = documentDescriptor(\n snapshot,\n this.options,\n transition.toUri,\n transition.textSnapshot,\n )\n if (!descriptor) {\n this.detachDocument()\n this.pendingUriProjection = pendingUriProjection(transition)\n return true\n }\n\n this.transitionDocument(descriptor, transition.syncPoint)\n return true\n }\n\n private detachDocument(): void {\n const active = this.document\n const attachment = this.attachment\n this.attachment = null\n this.document = null\n this.diagnosticItems = []\n this.syncPoint = null\n this.options.onDocumentClosed()\n if (!active) return\n\n this.presenter.clear()\n if (attachment) this.workspace.closeDocument(attachment)\n this.presenter.publishSummary(active.uri, active.lspVersion, [], 'reset')\n }\n\n private matchesTransitionSource(\n snapshot: LanguageServerDocumentSnapshot,\n transition: LanguageServerDocumentUriTransition,\n ): boolean {\n const active = this.document\n const point = this.syncPoint\n if (!active || !this.attachment || !point) return false\n if (active.uri !== transition.fromUri) return false\n if (active.textSnapshot !== transition.textSnapshot) return false\n if (snapshot.textSnapshot !== transition.textSnapshot) return false\n if (point.revision !== transition.syncPoint.revision) return false\n if (point.textVersion !== transition.syncPoint.textVersion) return false\n return point.segment !== transition.syncPoint.segment\n }\n\n private projectedDocumentUri(\n snapshot: LanguageServerDocumentSnapshot,\n ): lsp.DocumentUri | undefined {\n const projection = this.pendingUriProjection\n if (!projection) return undefined\n if (snapshot.documentSyncPoint.segment !== projection.segment) {\n this.pendingUriProjection = null\n return undefined\n }\n const uri = documentUri(snapshot, this.options)\n if (uri === null) {\n this.pendingUriProjection = null\n return undefined\n }\n\n if (uri === projection.fromUri) return projection.toUri\n this.pendingUriProjection = null\n return undefined\n }\n\n public publishDiagnostics(params: unknown): void {\n const diagnostics = publishDiagnosticsParams(params)\n if (!diagnostics) return\n\n const active = this.document\n if (!active) return\n if (diagnostics.uri !== active.uri) return\n if (diagnostics.version !== null && diagnostics.version !== active.lspVersion) return\n\n this.replaceDiagnostics(active, diagnostics.version, diagnostics.diagnostics)\n }\n\n public pullDiagnostics(\n uri: lsp.DocumentUri,\n version: number,\n diagnostics: readonly lsp.Diagnostic[],\n ): void {\n const active = this.document\n if (!active || active.uri !== uri || active.lspVersion !== version) return\n\n this.replaceDiagnostics(active, version, diagnostics)\n }\n\n public clearDiagnostics(): void {\n const active = this.document\n this.diagnosticItems = []\n this.presenter.clear()\n if (!active) return\n\n this.presenter.publishSummary(active.uri, active.lspVersion, [], 'reset')\n }\n\n private openOrUpdateDocument(\n descriptor: DocumentDescriptor,\n change: EditorContributionChange | null,\n snapshot: LanguageServerDocumentSnapshot,\n ): void {\n const active = this.document\n if (!active) {\n this.openDocument(descriptor, snapshot.documentSyncPoint)\n return\n }\n\n if (active.uri !== descriptor.uri) {\n this.replaceOrTransitionDocument(descriptor, snapshot.documentSyncPoint)\n return\n }\n if (active.languageId !== descriptor.languageId) {\n this.openDocument(descriptor, snapshot.documentSyncPoint)\n return\n }\n if (sameSyncPoint(this.syncPoint, snapshot.documentSyncPoint)) return\n this.updateDocument(descriptor, change, snapshot)\n }\n\n private replaceDiagnostics(\n active: ActiveDocument,\n version: number | null,\n diagnostics: readonly lsp.Diagnostic[],\n ): void {\n this.diagnosticItems = diagnostics\n this.presenter.render(active, diagnostics)\n this.presenter.publishSummary(active.uri, version, diagnostics, 'result')\n }\n\n private openDocument(descriptor: DocumentDescriptor, syncPoint: DocumentSyncPoint): void {\n this.close()\n const result = this.workspace.openDocumentSnapshot({\n uri: descriptor.uri,\n languageId: descriptor.languageId,\n textSnapshot: descriptor.textSnapshot,\n lineStarts: descriptor.lineStarts,\n sourceRevision: syncPoint.revision,\n sourceSegment: syncPoint.segment,\n onDocumentTransition: (transition) => this.adoptDocumentTransition(transition),\n })\n this.attachment = result.attachment\n this.document = activeDocument(descriptor, result.document.version)\n this.syncPoint = syncPoint\n }\n\n private replaceOrTransitionDocument(\n descriptor: DocumentDescriptor,\n syncPoint: DocumentSyncPoint,\n ): void {\n if (!isSharedUriTransition(this.document, this.syncPoint, descriptor, syncPoint)) {\n this.openDocument(descriptor, syncPoint)\n return\n }\n this.transitionDocument(descriptor, syncPoint)\n }\n\n private transitionDocument(descriptor: DocumentDescriptor, syncPoint: DocumentSyncPoint): void {\n const attachment = this.attachment\n if (!attachment) throw new Error('An active LSP document must retain its workspace attachment.')\n\n const result = this.workspace.transitionDocumentUri(attachment, {\n uri: descriptor.uri,\n languageId: descriptor.languageId,\n textSnapshot: descriptor.textSnapshot,\n lineStarts: descriptor.lineStarts,\n sourceRevision: syncPoint.revision,\n sourceSegment: syncPoint.segment,\n sourceTextVersion: syncPoint.textVersion,\n })\n this.document = activeDocument(descriptor, result.document.version)\n this.syncPoint = syncPoint\n }\n\n private updateDocument(\n descriptor: DocumentDescriptor,\n change: EditorContributionChange | null,\n snapshot: LanguageServerDocumentSnapshot,\n ): void {\n const active = this.document\n const diagnostics = projectDiagnosticsInSnapshot(this.diagnosticItems, {\n previousDocument: active ?? descriptor,\n nextDocument: descriptor,\n change,\n })\n const changes = changesSinceLastSync(\n snapshot,\n this.syncPoint,\n this.logicalRevisionScope,\n change,\n active?.textSnapshot ?? descriptor.textSnapshot,\n descriptor.textSnapshot,\n )\n recordLspPerformanceDiagnostic('lsp.documentSync.editChain', {\n chained: changes.edits === null ? 'null' : changes.edits.length,\n logicalRevisionCount: changes.logicalRevisionCount,\n activeTextVersion: active?.textVersion ?? -1,\n snapshotTextVersion: snapshot.textVersion,\n changeEditCount: change?.edits.length ?? -1,\n })\n const document = this.synchronizeWorkspaceDocument(descriptor, changes)\n this.document = activeDocument(descriptor, document.version)\n this.syncPoint = changes.syncPointAfter\n if (diagnostics === this.diagnosticItems) return\n\n this.diagnosticItems = diagnostics\n this.presenter.render(descriptor, diagnostics)\n }\n\n private synchronizeWorkspaceDocument(\n descriptor: DocumentDescriptor,\n changes: SyncChanges,\n ): ReturnType<LspWorkspace['updateDocumentSnapshot']> {\n const source = {\n textSnapshot: descriptor.textSnapshot,\n lineStarts: descriptor.lineStarts,\n sourceRevision: changes.syncPointAfter.revision,\n sourceSegment: changes.syncPointAfter.segment,\n }\n if (changes.logicalRevisionCount === 0) {\n return this.workspace.adoptUnchangedDocumentSource(descriptor.uri, source)\n }\n\n return this.workspace.updateDocumentSnapshot(descriptor.uri, {\n ...source,\n edits: changes.edits,\n logicalRevisionCount: changes.logicalRevisionCount,\n })\n }\n\n private adoptDocumentTransition(transition: LspDocumentTransitionNotification): void {\n const active = this.document\n if (!active) return\n\n this.diagnosticItems = []\n this.presenter.clear()\n this.presenter.publishSummary(active.uri, active.lspVersion, [], 'reset')\n this.pendingUriProjection = {\n fromUri: active.uri,\n toUri: transition.document.uri,\n segment: transition.sourceSegment as DocumentSyncSegment,\n }\n this.document = activeDocumentForTransition(active, transition)\n this.syncPoint = {\n revision: transition.sourceRevision,\n segment: transition.sourceSegment as DocumentSyncSegment,\n textVersion: transition.sourceTextVersion,\n }\n }\n}\n\ntype PendingUriProjection = {\n readonly fromUri: lsp.DocumentUri\n readonly toUri: lsp.DocumentUri\n readonly segment: DocumentSyncSegment\n}\n\nfunction pendingUriProjection(\n transition: LanguageServerDocumentUriTransition,\n): PendingUriProjection {\n return {\n fromUri: transition.fromUri,\n toUri: transition.toUri,\n segment: transition.syncPoint.segment,\n }\n}\n\ntype SyncChanges = {\n readonly edits: readonly TextEdit[] | null\n readonly logicalRevisionCount: number\n readonly syncPointAfter: DocumentSyncPoint\n}\n\nfunction changesSinceLastSync(\n snapshot: LanguageServerDocumentSnapshot,\n point: DocumentSyncPoint | null,\n scope: DocumentLogicalRevisionScope,\n change: EditorContributionChange | null,\n previousTextSnapshot: LspTextSnapshot,\n nextTextSnapshot: LspTextSnapshot,\n): SyncChanges {\n if (!point) {\n return fallbackSyncChanges(\n snapshot,\n null,\n change,\n scope,\n previousTextSnapshot,\n nextTextSnapshot,\n )\n }\n\n const changes = snapshot.changesSinceDocumentSyncPoint(point, scope)\n if (changes) {\n return {\n edits: changes.edits,\n logicalRevisionCount: changes.logicalRevisionCount,\n syncPointAfter: changes.syncPointAfter,\n }\n }\n return fallbackSyncChanges(snapshot, point, change, scope, previousTextSnapshot, nextTextSnapshot)\n}\n\nfunction fallbackSyncChanges(\n snapshot: LanguageServerDocumentSnapshot,\n point: DocumentSyncPoint | null,\n change: EditorContributionChange | null,\n scope: DocumentLogicalRevisionScope,\n previousTextSnapshot: LspTextSnapshot,\n nextTextSnapshot: LspTextSnapshot,\n): SyncChanges {\n const nextPoint = snapshot.documentSyncPoint\n const textChanged =\n previousTextSnapshot !== nextTextSnapshot ||\n point === null ||\n point.textVersion !== nextPoint.textVersion\n return {\n edits: null,\n logicalRevisionCount: fallbackLogicalRevisionCount(\n change,\n scope,\n textChanged,\n point,\n nextPoint,\n ),\n syncPointAfter: nextPoint,\n }\n}\n\nfunction fallbackLogicalRevisionCount(\n change: EditorContributionChange | null,\n scope: DocumentLogicalRevisionScope,\n textChanged: boolean,\n point: DocumentSyncPoint | null,\n nextPoint: DocumentSyncPoint,\n): number {\n if (change?.logicalRevisionScope === scope) return change.logicalRevisionCount\n if (!textChanged) return 0\n if (!point) return 1\n return Math.max(1, nextPoint.textVersion - point.textVersion)\n}\n\nfunction sameSyncPoint(left: DocumentSyncPoint | null, right: DocumentSyncPoint): boolean {\n if (!left) return false\n return (\n left.revision === right.revision &&\n left.segment === right.segment &&\n left.textVersion === right.textVersion\n )\n}\n\nfunction isSharedUriTransition(\n active: ActiveDocument | null,\n currentPoint: DocumentSyncPoint | null,\n descriptor: DocumentDescriptor,\n nextPoint: DocumentSyncPoint,\n): boolean {\n if (!active || !currentPoint) return false\n if (active.textSnapshot !== descriptor.textSnapshot) return false\n if (currentPoint.revision !== nextPoint.revision) return false\n if (currentPoint.textVersion !== nextPoint.textVersion) return false\n return currentPoint.segment !== nextPoint.segment\n}\n\nfunction activeDocument(descriptor: DocumentDescriptor, lspVersion: number): ActiveDocument {\n return {\n uri: descriptor.uri,\n languageId: descriptor.languageId,\n textSnapshot: descriptor.textSnapshot,\n lineStarts: descriptor.lineStarts,\n textVersion: descriptor.textVersion,\n lspVersion,\n }\n}\n\nfunction activeDocumentForTransition(\n active: ActiveDocument,\n transition: LspDocumentTransitionNotification,\n): ActiveDocument {\n const document = transition.document\n return {\n uri: document.uri,\n languageId: document.languageId,\n textSnapshot: document.textSnapshot,\n lineStarts: document.lineStarts,\n textVersion: active.textVersion,\n lspVersion: document.version,\n }\n}\n\nfunction documentUri(\n snapshot: LanguageServerDocumentSnapshot,\n options: LanguageServerDocumentSyncOptions,\n): lsp.DocumentUri | null {\n if (!snapshot.documentId) return null\n if (options.uriForDocument) return options.uriForDocument(snapshot)\n return pathOrUriToDocumentUri(snapshot.documentId)\n}\n\nfunction documentDescriptor(\n snapshot: LanguageServerDocumentSnapshot,\n options: LanguageServerDocumentSyncOptions,\n projectedUri?: lsp.DocumentUri,\n projectedTextSnapshot?: LspTextSnapshot,\n): DocumentDescriptor | null {\n if (!snapshot.languageId) return null\n if (options.shouldSyncLanguageId?.(snapshot.languageId, snapshot) === false) return null\n\n const resolvedUri = documentUri(snapshot, options)\n if (resolvedUri === null) return null\n const uri = projectedUri ?? resolvedUri\n if (options.shouldSyncUri?.(uri, snapshot) === false) return null\n\n const document = viewDocumentSnapshot(snapshot)\n return {\n uri,\n // `shouldSyncLanguageId` above still filters on the view's id, not this one.\n languageId: options.languageIdForDocument?.(snapshot.languageId, uri) ?? snapshot.languageId,\n textSnapshot: projectedTextSnapshot ?? document.textSnapshot,\n lineStarts: document.lineStarts,\n textVersion: snapshot.textVersion,\n }\n}\n\nexport function activeDocumentForSnapshot(\n snapshot: LanguageServerDocumentSnapshot,\n options: LanguageServerDocumentSyncOptions,\n): ActiveDocument | null {\n const descriptor = documentDescriptor(snapshot, options)\n return descriptor ? activeDocument(descriptor, 0) : null\n}\n\nfunction publishDiagnosticsParams(params: unknown): {\n readonly uri: lsp.DocumentUri\n readonly version: number | null\n readonly diagnostics: readonly lsp.Diagnostic[]\n} | null {\n if (!isRecord(params)) return null\n if (typeof params.uri !== 'string') return null\n if (!Array.isArray(params.diagnostics)) return null\n\n return {\n uri: params.uri,\n version: typeof params.version === 'number' ? params.version : null,\n diagnostics: params.diagnostics as lsp.Diagnostic[],\n }\n}\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === 'object' && value !== null && !Array.isArray(value)\n"],"mappings":";;;;;;AA+CA,IAAa,eAAb,MAA0B;CASL;CACA;CACA;CAVnB,aAA4D;CAC5D,WAA0C;CAC1C,kBAAqD,CAAC;CACtD;CACA,uBAA4D;CAC5D,YAA8C;CAE9C,YACE,WACA,WACA,SACA;EAHiB,KAAA,YAAA;EACA,KAAA,YAAA;EACA,KAAA,UAAA;EAEjB,KAAK,uBAAuB,QAAQ;CACtC;CAEA,IAAW,iBAAwC;EACjD,OAAO,KAAK;CACd;CAEA,IAAW,cAAyC;EAClD,OAAO,KAAK;CACd;CAEA,WACE,MACA,UACS;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,aAAa,SAAS;CACxB;AACF;AAEA,SAAgB,0BACd,UACA,SACuB;CACvB,MAAM,aAAa,mBAAmB,UAAU,OAAO;CACvD,OAAO,aAAa,eAAe,YAAY,CAAC,IAAI;AACtD;AAEA,SAAS,yBAAyB,QAIzB;CACP,IAAI,CAAC,SAAS,MAAM,GAAG,OAAO;CAC9B,IAAI,OAAO,OAAO,QAAQ,UAAU,OAAO;CAC3C,IAAI,CAAC,MAAM,QAAQ,OAAO,WAAW,GAAG,OAAO;CAE/C,OAAO;EACL,KAAK,OAAO;EACZ,SAAS,OAAO,OAAO,YAAY,WAAW,OAAO,UAAU;EAC/D,aAAa,OAAO;CACtB;AACF;AAEA,IAAM,YAAY,UAChB,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK"}
1
+ {"version":3,"file":"documentSync.js","names":[],"sources":["../src/documentSync.ts"],"sourcesContent":["import type { LanguageServerDocumentSnapshot, LanguageServerDocumentSyncOptions } from './types'\nimport type {\n DocumentLogicalRevisionScope,\n DocumentSyncSegment,\n} from '@singapore-editor/core/document'\nimport type { EditorViewContributionUpdateKind } from '@singapore-editor/core/extensions'\nimport type { LspTextDocumentSnapshot, LspWorkspace } from '@singapore-editor/lsp'\nimport type * as lsp from 'vscode-languageserver-protocol'\nimport { projectDiagnosticsInSnapshot } from './diagnosticProjection'\nimport type { LanguageServerDocumentUriTransition } from './documentSyncController'\nimport { pathOrUriToDocumentUri } from './paths'\nimport type { ActiveDocument, DocumentDescriptor } from './pluginTypes'\nimport { viewDocumentSnapshot } from './viewDocumentSnapshot'\nimport {\n observeLanguageServerSource,\n retainLanguageServerSource,\n type LanguageServerSourceConnection,\n type LanguageServerSourceOwner,\n type LanguageServerSourcePublication,\n} from './retainedSource'\n\nexport type DocumentSyncSummaryKind = 'result' | 'reset'\nexport type DocumentSyncDiagnosticsPresenter = {\n clear(): void\n render(document: LspTextDocumentSnapshot, diagnostics: readonly lsp.Diagnostic[]): void\n publishSummary(\n uri: lsp.DocumentUri,\n version: number | null,\n diagnostics: readonly lsp.Diagnostic[],\n kind: DocumentSyncSummaryKind,\n ): void\n}\nexport type DocumentSyncOptions = LanguageServerDocumentSyncOptions & {\n readonly logicalRevisionScope: DocumentLogicalRevisionScope\n getSourceOwner(): LanguageServerSourceOwner | null\n getConnection(): LanguageServerSourceConnection | null\n onDocumentClosed(): void\n onDocumentChanged(): void\n onError(error: unknown): void\n}\ntype SourceLease = NonNullable<ReturnType<typeof retainLanguageServerSource>>\ntype Binding = {\n readonly source: LanguageServerSourceOwner\n readonly connection: LanguageServerSourceConnection\n readonly uri: string\n readonly languageId: string\n readonly lease: SourceLease\n}\ntype UriProjection = {\n readonly fromUri: string\n readonly toUri: string\n readonly segment: DocumentSyncSegment\n readonly previousSegment: DocumentSyncSegment\n}\n\nexport class DocumentSync {\n private binding: Binding | null = null\n private document: ActiveDocument | null = null\n private diagnosticItems: readonly lsp.Diagnostic[] = []\n private pendingUriProjection: UriProjection | null = null\n private readonly unsubscribe: () => void\n\n constructor(\n private readonly workspace: LspWorkspace,\n private readonly presenter: DocumentSyncDiagnosticsPresenter,\n private readonly options: DocumentSyncOptions,\n ) {\n this.unsubscribe = observeLanguageServerSource(workspace, {\n deliver: this.adoptPublication,\n onError: options.onError,\n })\n }\n get activeDocument(): ActiveDocument | null {\n return this.document\n }\n get diagnostics(): readonly lsp.Diagnostic[] {\n return this.diagnosticItems\n }\n\n shouldSync(\n kind: EditorViewContributionUpdateKind,\n snapshot: LanguageServerDocumentSnapshot,\n ): boolean {\n if (kind === 'document' || kind === 'content' || kind === 'clear') return true\n const descriptor = this.descriptor(snapshot)\n return (\n descriptor?.uri !== this.binding?.uri || descriptor?.languageId !== this.binding?.languageId\n )\n }\n\n async sync(snapshot: LanguageServerDocumentSnapshot): Promise<void> {\n const descriptor = this.descriptor(snapshot)\n const source = this.options.getSourceOwner()\n const connection = this.options.getConnection()\n if (!descriptor || !source || !connection) {\n this.detach()\n return\n }\n const binding = this.bind(source, connection, descriptor)\n await binding?.lease.request()\n }\n\n close(): void {\n this.pendingUriProjection = null\n this.detach()\n }\n dispose(): void {\n this.unsubscribe()\n this.close()\n }\n\n transitionDocumentUri(\n snapshot: LanguageServerDocumentSnapshot,\n transition: LanguageServerDocumentUriTransition,\n ): boolean {\n const active = this.document\n const binding = this.binding\n if (!active || !binding || active.uri !== transition.fromUri) return false\n if (active.sourceSegment !== transition.previousSyncPoint.segment) return false\n if (active.sourceRevision > transition.previousSyncPoint.revision) return false\n if (\n transition.previousSyncPoint.revision !== transition.syncPoint.revision ||\n transition.previousSyncPoint.textVersion !== transition.syncPoint.textVersion\n )\n return false\n if (transition.previousSyncPoint.segment === transition.syncPoint.segment) return false\n const descriptor = documentDescriptor(snapshot, this.options, transition.toUri)\n if (!descriptor) {\n this.close()\n return true\n }\n this.pendingUriProjection = {\n fromUri: documentUri(snapshot, this.options) ?? transition.fromUri,\n toUri: transition.toUri,\n segment: transition.syncPoint.segment,\n previousSegment: transition.previousSyncPoint.segment,\n }\n const source = this.options.getSourceOwner()\n const connection = this.options.getConnection()\n if (!source || !connection) {\n this.detach()\n return true\n }\n const next = this.bind(source, connection, descriptor)\n void next?.lease.request().catch(this.options.onError)\n return true\n }\n\n publishDiagnostics(params: unknown): void {\n const diagnostics = publishDiagnosticsParams(params)\n const active = this.document\n if (!diagnostics || !active || diagnostics.uri !== active.uri) return\n if (diagnostics.version !== null && diagnostics.version !== active.lspVersion) return\n this.replaceDiagnostics(active, diagnostics.version, diagnostics.diagnostics)\n }\n pullDiagnostics(\n uri: lsp.DocumentUri,\n version: number,\n diagnostics: readonly lsp.Diagnostic[],\n ): void {\n const active = this.document\n if (!active || active.uri !== uri || active.lspVersion !== version) return\n this.replaceDiagnostics(active, version, diagnostics)\n }\n clearDiagnostics(): void {\n const active = this.document\n this.diagnosticItems = []\n this.presenter.clear()\n if (active) this.presenter.publishSummary(active.uri, active.lspVersion, [], 'reset')\n }\n\n private descriptor(snapshot: LanguageServerDocumentSnapshot): DocumentDescriptor | null {\n const projection = this.pendingUriProjection\n const uri = documentUri(snapshot, this.options)\n if (\n projection &&\n uri === projection.fromUri &&\n (snapshot.documentSyncPoint.segment === projection.segment ||\n snapshot.documentSyncPoint.segment === projection.previousSegment)\n )\n return documentDescriptor(snapshot, this.options, projection.toUri)\n this.pendingUriProjection = null\n return documentDescriptor(snapshot, this.options)\n }\n private bind(\n source: LanguageServerSourceOwner,\n connection: LanguageServerSourceConnection,\n descriptor: DocumentDescriptor,\n ): Binding | null {\n const previous = this.binding\n if (\n previous &&\n sameOwner(previous.source, source) &&\n previous.connection === connection &&\n previous.uri === descriptor.uri &&\n previous.languageId === descriptor.languageId\n )\n return previous\n this.detach()\n const lease = retainLanguageServerSource({\n ...source,\n workspace: this.workspace,\n uri: descriptor.uri,\n languageId: descriptor.languageId,\n logicalRevisionScope: this.options.logicalRevisionScope,\n connection,\n })\n this.binding = lease\n ? { source, connection, uri: descriptor.uri, languageId: descriptor.languageId, lease }\n : null\n return this.binding\n }\n private detach(): void {\n const binding = this.binding\n this.binding = null\n try {\n binding?.lease.dispose()\n } finally {\n this.clearDocument()\n }\n }\n private clearDocument(): void {\n const active = this.document\n this.document = null\n this.diagnosticItems = []\n this.options.onDocumentClosed()\n this.presenter.clear()\n if (active) this.presenter.publishSummary(active.uri, active.lspVersion, [], 'reset')\n }\n private readonly adoptPublication = (publication: LanguageServerSourcePublication): void => {\n if (publication.runtimeSessionId !== this.binding?.lease.runtimeSessionId) return\n const next = publication.document\n if (!next) {\n this.clearDocument()\n return\n }\n const previous = this.document\n if (\n previous?.sourceRevision === next.sourceRevision &&\n previous.sourceSegment === next.sourceSegment &&\n previous.lspVersion === next.version\n )\n return\n if (previous && previous.textSnapshot !== next.textSnapshot) {\n this.diagnosticItems = projectDiagnosticsInSnapshot(this.diagnosticItems, {\n previousDocument: previous,\n nextDocument: next,\n change: publication.edits ? { edits: publication.edits } : null,\n })\n }\n this.document = {\n ...next,\n textVersion: publication.point?.textVersion ?? 0,\n lspVersion: next.version,\n }\n this.presenter.render(this.document, this.diagnosticItems)\n this.options.onDocumentChanged()\n }\n private replaceDiagnostics(\n active: ActiveDocument,\n version: number | null,\n diagnostics: readonly lsp.Diagnostic[],\n ): void {\n this.diagnosticItems = diagnostics\n this.presenter.render(active, diagnostics)\n this.presenter.publishSummary(active.uri, version, diagnostics, 'result')\n }\n}\n\nfunction sameOwner(left: LanguageServerSourceOwner, right: LanguageServerSourceOwner): boolean {\n if ('buffer' in left && 'buffer' in right) return left.buffer === right.buffer\n if ('contributions' in left && 'contributions' in right)\n return left.contributions === right.contributions\n return false\n}\n\nfunction activeDocument(descriptor: DocumentDescriptor, lspVersion: number): ActiveDocument {\n return {\n uri: descriptor.uri,\n languageId: descriptor.languageId,\n textSnapshot: descriptor.textSnapshot,\n lineStarts: descriptor.lineStarts,\n textVersion: descriptor.textVersion,\n lspVersion,\n sourceRevision: descriptor.sourceRevision,\n sourceSegment: descriptor.sourceSegment,\n }\n}\n\nfunction documentUri(\n snapshot: LanguageServerDocumentSnapshot,\n options: LanguageServerDocumentSyncOptions,\n): lsp.DocumentUri | null {\n if (options.uriForDocument) return options.uriForDocument(snapshot)\n return snapshot.documentId ? pathOrUriToDocumentUri(snapshot.documentId) : null\n}\n\nfunction documentDescriptor(\n snapshot: LanguageServerDocumentSnapshot,\n options: LanguageServerDocumentSyncOptions,\n projectedUri?: lsp.DocumentUri,\n): DocumentDescriptor | null {\n if (!snapshot.languageId) return null\n if (options.shouldSyncLanguageId?.(snapshot.languageId, snapshot) === false) return null\n\n const resolvedUri = documentUri(snapshot, options)\n if (resolvedUri === null) return null\n const uri = projectedUri ?? resolvedUri\n if (options.shouldSyncUri?.(uri, snapshot) === false) return null\n\n const document = viewDocumentSnapshot(snapshot)\n return {\n uri,\n // `shouldSyncLanguageId` above still filters on the view's id, not this one.\n languageId: options.languageIdForDocument?.(snapshot.languageId, uri) ?? snapshot.languageId,\n textSnapshot: document.textSnapshot,\n lineStarts: document.lineStarts,\n textVersion: snapshot.textVersion,\n sourceRevision: snapshot.documentSyncPoint.revision,\n sourceSegment: snapshot.documentSyncPoint.segment,\n }\n}\n\nexport function activeDocumentForSnapshot(\n snapshot: LanguageServerDocumentSnapshot,\n options: LanguageServerDocumentSyncOptions,\n): ActiveDocument | null {\n const descriptor = documentDescriptor(snapshot, options)\n return descriptor ? activeDocument(descriptor, 0) : null\n}\n\nfunction publishDiagnosticsParams(params: unknown): {\n readonly uri: lsp.DocumentUri\n readonly version: number | null\n readonly diagnostics: readonly lsp.Diagnostic[]\n} | null {\n if (!isRecord(params)) return null\n if (typeof params.uri !== 'string') return null\n if (!Array.isArray(params.diagnostics)) return null\n\n return {\n uri: params.uri,\n version: typeof params.version === 'number' ? params.version : null,\n diagnostics: params.diagnostics as lsp.Diagnostic[],\n }\n}\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === 'object' && value !== null && !Array.isArray(value)\n"],"mappings":";;;;;AAuDA,IAAa,eAAb,MAA0B;CAQL;CACA;CACA;CATnB,UAAkC;CAClC,WAA0C;CAC1C,kBAAqD,CAAC;CACtD,uBAAqD;CACrD;CAEA,YACE,WACA,WACA,SACA;EAHiB,KAAA,YAAA;EACA,KAAA,YAAA;EACA,KAAA,UAAA;EAEjB,KAAK,cAAc,4BAA4B,WAAW;GACxD,SAAS,KAAK;GACd,SAAS,QAAQ;EACnB,CAAC;CACH;CACA,IAAI,iBAAwC;EAC1C,OAAO,KAAK;CACd;CACA,IAAI,cAAyC;EAC3C,OAAO,KAAK;CACd;CAEA,WACE,MACA,UACS;EACT,IAAI,SAAS,cAAc,SAAS,aAAa,SAAS,SAAS,OAAO;EAC1E,MAAM,aAAa,KAAK,WAAW,QAAQ;EAC3C,OACE,YAAY,QAAQ,KAAK,SAAS,OAAO,YAAY,eAAe,KAAK,SAAS;CAEtF;CAEA,MAAM,KAAK,UAAyD;EAClE,MAAM,aAAa,KAAK,WAAW,QAAQ;EAC3C,MAAM,SAAS,KAAK,QAAQ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O;CAC3C,IAAI,CAAC,MAAM,QAAQ,OAAO,WAAW,GAAG,OAAO;CAE/C,OAAO;EACL,KAAK,OAAO;EACZ,SAAS,OAAO,OAAO,YAAY,WAAW,OAAO,UAAU;EAC/D,aAAa,OAAO;CACtB;AACF;AAEA,IAAM,YAAY,UAChB,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK"}
@@ -1,19 +1,17 @@
1
1
  import type { LanguageServerDocumentSnapshot } from './types';
2
- import type { DocumentSyncPoint, TextSnapshot } from '@singapore-editor/core/document';
2
+ import type { DocumentSyncPoint } from '@singapore-editor/core/document';
3
3
  import type { EditorDisposable } from '@singapore-editor/core/extensions';
4
- import type { LspWorkspace } from '@singapore-editor/lsp';
5
4
  import type * as lsp from 'vscode-languageserver-protocol';
6
5
  import type { DocumentSync } from './documentSync';
7
6
  export type LanguageServerDocumentUriTransition = {
8
7
  readonly fromUri: lsp.DocumentUri;
9
8
  readonly toUri: lsp.DocumentUri;
10
- readonly textSnapshot: TextSnapshot;
9
+ readonly previousSyncPoint: DocumentSyncPoint;
11
10
  readonly syncPoint: DocumentSyncPoint;
12
11
  };
13
12
  export type LanguageServerDocumentSyncControllerRegistration = {
14
13
  readonly getSnapshot: () => LanguageServerDocumentSnapshot;
15
14
  readonly sync: DocumentSync;
16
- readonly workspace: LspWorkspace;
17
15
  };
18
16
  /**
19
17
  * Projects a live document identity change through every mounted language-server lane immediately.
@@ -1 +1 @@
1
- {"version":3,"file":"documentSyncController.d.ts","sourceRoot":"","sources":["../src/documentSyncController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,SAAS,CAAA;AAC7D,OAAO,KAAK,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA;AACtF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAA;AACzE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AAC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AAA;IAC/B,QAAQ,CAAC,iBAAiB,EAAE,iBAAiB,CAAA;IAC7C,QAAQ,CAAC,SAAS,EAAE,iBAAiB,CAAA;CACtC,CAAA;AAED,MAAM,MAAM,gDAAgD,GAAG;IAC7D,QAAQ,CAAC,WAAW,EAAE,MAAM,8BAA8B,CAAA;IAC1D,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAA;CAC5B,CAAA;AAED;;GAEG;AACH,qBAAa,oCAAoC;IAC/C,OAAO,CAAC,QAAQ,CAAC,aAAa,CAA8D;IAErF,QAAQ,CACb,YAAY,EAAE,gDAAgD,GAC7D,gBAAgB,CAKlB;IAEM,qBAAqB,CAAC,UAAU,EAAE,mCAAmC,GAAG,IAAI,CAIlF;CACF"}
@@ -1,4 +1,4 @@
1
- //#region src/documentSyncController.ts
1
+ // src/documentSyncController.ts
2
2
  /**
3
3
  * Projects a live document identity change through every mounted language-server lane immediately.
4
4
  */
@@ -9,16 +9,9 @@ var LanguageServerDocumentSyncController = class {
9
9
  return { dispose: () => this.registrations.delete(registration) };
10
10
  }
11
11
  transitionDocumentUri(transition) {
12
- const transitionedWorkspaces = /* @__PURE__ */ new Set();
13
- for (const registration of this.registrations) {
14
- if (transitionedWorkspaces.has(registration.workspace)) continue;
15
- if (!registration.sync.transitionDocumentUri(registration.getSnapshot(), transition)) continue;
16
- if (registration.sync.activeDocument?.uri !== transition.toUri) continue;
17
- transitionedWorkspaces.add(registration.workspace);
18
- }
12
+ for (const registration of this.registrations) registration.sync.transitionDocumentUri(registration.getSnapshot(), transition);
19
13
  }
20
14
  };
21
- //#endregion
22
15
  export { LanguageServerDocumentSyncController };
23
16
 
24
17
  //# sourceMappingURL=documentSyncController.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"documentSyncController.js","names":[],"sources":["../src/documentSyncController.ts"],"sourcesContent":["import type { LanguageServerDocumentSnapshot } from './types'\nimport type { DocumentSyncPoint, TextSnapshot } from '@singapore-editor/core/document'\nimport type { EditorDisposable } from '@singapore-editor/core/extensions'\nimport type { LspWorkspace } from '@singapore-editor/lsp'\nimport type * as lsp from 'vscode-languageserver-protocol'\n\nimport type { DocumentSync } from './documentSync'\n\nexport type LanguageServerDocumentUriTransition = {\n readonly fromUri: lsp.DocumentUri\n readonly toUri: lsp.DocumentUri\n readonly textSnapshot: TextSnapshot\n readonly syncPoint: DocumentSyncPoint\n}\n\nexport type LanguageServerDocumentSyncControllerRegistration = {\n readonly getSnapshot: () => LanguageServerDocumentSnapshot\n readonly sync: DocumentSync\n readonly workspace: LspWorkspace\n}\n\n/**\n * Projects a live document identity change through every mounted language-server lane immediately.\n */\nexport class LanguageServerDocumentSyncController {\n private readonly registrations = new Set<LanguageServerDocumentSyncControllerRegistration>()\n\n public register(\n registration: LanguageServerDocumentSyncControllerRegistration,\n ): EditorDisposable {\n this.registrations.add(registration)\n return {\n dispose: () => this.registrations.delete(registration),\n }\n }\n\n public transitionDocumentUri(transition: LanguageServerDocumentUriTransition): void {\n const transitionedWorkspaces = new Set<LspWorkspace>()\n for (const registration of this.registrations) {\n if (transitionedWorkspaces.has(registration.workspace)) continue\n\n const handled = registration.sync.transitionDocumentUri(\n registration.getSnapshot(),\n transition,\n )\n if (!handled) continue\n if (registration.sync.activeDocument?.uri !== transition.toUri) continue\n transitionedWorkspaces.add(registration.workspace)\n }\n }\n}\n"],"mappings":";;;;AAwBA,IAAa,uCAAb,MAAkD;CAChD,gCAAiC,IAAI,IAAsD;CAE3F,SACE,cACkB;EAClB,KAAK,cAAc,IAAI,YAAY;EACnC,OAAO,EACL,eAAe,KAAK,cAAc,OAAO,YAAY,EACvD;CACF;CAEA,sBAA6B,YAAuD;EAClF,MAAM,yCAAyB,IAAI,IAAkB;EACrD,KAAK,MAAM,gBAAgB,KAAK,eAAe;GAC7C,IAAI,uBAAuB,IAAI,aAAa,SAAS,GAAG;GAMxD,IAAI,CAJY,aAAa,KAAK,sBAChC,aAAa,YAAY,GACzB,UAEG,GAAS;GACd,IAAI,aAAa,KAAK,gBAAgB,QAAQ,WAAW,OAAO;GAChE,uBAAuB,IAAI,aAAa,SAAS;EACnD;CACF;AACF"}
1
+ {"version":3,"file":"documentSyncController.js","names":[],"sources":["../src/documentSyncController.ts"],"sourcesContent":["import type { LanguageServerDocumentSnapshot } from './types'\nimport type { DocumentSyncPoint } from '@singapore-editor/core/document'\nimport type { EditorDisposable } from '@singapore-editor/core/extensions'\nimport type * as lsp from 'vscode-languageserver-protocol'\n\nimport type { DocumentSync } from './documentSync'\n\nexport type LanguageServerDocumentUriTransition = {\n readonly fromUri: lsp.DocumentUri\n readonly toUri: lsp.DocumentUri\n readonly previousSyncPoint: DocumentSyncPoint\n readonly syncPoint: DocumentSyncPoint\n}\n\nexport type LanguageServerDocumentSyncControllerRegistration = {\n readonly getSnapshot: () => LanguageServerDocumentSnapshot\n readonly sync: DocumentSync\n}\n\n/**\n * Projects a live document identity change through every mounted language-server lane immediately.\n */\nexport class LanguageServerDocumentSyncController {\n private readonly registrations = new Set<LanguageServerDocumentSyncControllerRegistration>()\n\n public register(\n registration: LanguageServerDocumentSyncControllerRegistration,\n ): EditorDisposable {\n this.registrations.add(registration)\n return {\n dispose: () => this.registrations.delete(registration),\n }\n }\n\n public transitionDocumentUri(transition: LanguageServerDocumentUriTransition): void {\n for (const registration of this.registrations) {\n registration.sync.transitionDocumentUri(registration.getSnapshot(), transition)\n }\n }\n}\n"],"mappings":";;;;AAsBA,IAAa,uCAAb,MAAkD;CAChD,gCAAiC,IAAI,IAAsD;CAE3F,SACE,cACkB;EAClB,KAAK,cAAc,IAAI,YAAY;EACnC,OAAO,EACL,eAAe,KAAK,cAAc,OAAO,YAAY,EACvD;CACF;CAEA,sBAA6B,YAAuD;EAClF,KAAK,MAAM,gBAAgB,KAAK,eAC9B,aAAa,KAAK,sBAAsB,aAAa,YAAY,GAAG,UAAU;CAElF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"formatOnType.d.ts","sourceRoot":"","sources":["../src/formatOnType.ts"],"names":[],"mappings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W,EAAE,qBAAqB,CAAC,mCAAmC,CAAC,CAAA;CACjF,CAAA;AA4BD,qBAAa,sBAAsB;IAKd,OAAO,CAAC,QAAQ,CAAC,OAAO;IAJ3C,OAAO,CAAC,OAAO,CAAmC;IAClD,OAAO,CAAC,SAAS,CAAQ;IACzB,OAAO,CAAC,QAAQ,CAAQ;IAExB,YAAoC,OAAO,EAAE,6BAA6B,EAAI;IAEvE,MAAM,CACX,QAAQ,EAAE,kBAAkB,EAC5B,IAAI,EAAE,gCAAgC,EACtC,MAAM,EAAE,wBAAwB,GAAG,IAAI,GACtC,IAAI,CAgBN;IAEM,OAAO,IAAI,IAAI,CAGrB;IAED;;;;;;;OAOG;IACH,OAAO,CAAC,mBAAmB;IAc3B,OAAO,CAAC,QAAQ;IAehB,OAAO,CAAC,YAAY;CAmBrB"}
@@ -1,5 +1,5 @@
1
1
  import { editorLanguageConfiguration, reindentEditsForRanges } from "@singapore-editor/core/extensions";
2
- //#region src/formatOnType.ts
2
+ // src/formatOnType.ts
3
3
  var FORMAT_ON_TYPE_WINDOW = 4096;
4
4
  var FormatOnTypeController = class {
5
5
  options;
@@ -192,7 +192,6 @@ function formatOnTypeWindow(snapshot, caretOffset) {
192
192
  caretOffset: caretOffset - start
193
193
  };
194
194
  }
195
- //#endregion
196
195
  export { FormatOnTypeController };
197
196
 
198
197
  //# sourceMappingURL=formatOnType.js.map
@@ -1,6 +1,6 @@
1
1
  import { REDIFF_LENGTH_LIMIT, minimalReplacementEdits } from "./minimalEdits.js";
2
2
  import { lspPositionToOffsetInSnapshot } from "@singapore-editor/lsp";
3
- //#region src/formatting.ts
3
+ // src/formatting.ts
4
4
  /**
5
5
  * Converts server formatting edits into buffer edits.
6
6
  *
@@ -46,7 +46,6 @@ function formattingOptions(tabSize) {
46
46
  tabSize: Math.max(1, tabSize)
47
47
  };
48
48
  }
49
- //#endregion
50
49
  export { formattingChangesText, formattingOptions, prepareFormattingEdits };
51
50
 
52
51
  //# sourceMappingURL=formatting.js.map