@@ -59,8 +59,6 @@ class DottyLanguageServer extends LanguageServer
59
59
private [this ] var myClient : WorksheetClient = _
60
60
def client : WorksheetClient = myClient
61
61
62
- private [this ] val worksheets : ConcurrentHashMap [URI , CompletableFuture [_]] = new ConcurrentHashMap ()
63
-
64
62
private [this ] var myDrivers : mutable.Map [ProjectConfig , InteractiveDriver ] = _
65
63
66
64
def drivers : Map [ProjectConfig , InteractiveDriver ] = thisServer.synchronized {
@@ -198,25 +196,33 @@ class DottyLanguageServer extends LanguageServer
198
196
diags.flatMap(diagnostic(_, positionMapper)).asJava))
199
197
}
200
198
201
- override def didChange (params : DidChangeTextDocumentParams ): Unit = thisServer.synchronized {
202
- checkMemory()
199
+ override def didChange (params : DidChangeTextDocumentParams ): Unit = {
203
200
val document = params.getTextDocument
204
201
val uri = new URI (document.getUri)
205
- val driver = driverFor(uri)
206
202
val worksheetMode = isWorksheet(uri)
207
203
208
- val change = params.getContentChanges.get(0 )
209
- assert(change.getRange == null , " TextDocumentSyncKind.Incremental support is not implemented" )
204
+ if (worksheetMode) {
205
+ Option (worksheets.get(uri)).foreach(_.cancel(true ))
206
+ }
210
207
211
- val (text, positionMapper) =
212
- if (worksheetMode) (wrapWorksheet(change.getText), Some (toUnwrappedPosition _))
213
- else (change.getText, None )
208
+ thisServer.synchronized {
209
+ checkMemory()
214
210
215
- val diags = driver.run (uri, text )
211
+ val driver = driverFor (uri)
216
212
217
- client.publishDiagnostics(new PublishDiagnosticsParams (
218
- document.getUri,
219
- diags.flatMap(diagnostic(_, positionMapper)).asJava))
213
+ val change = params.getContentChanges.get(0 )
214
+ assert(change.getRange == null , " TextDocumentSyncKind.Incremental support is not implemented" )
215
+
216
+ val (text, positionMapper) =
217
+ if (worksheetMode) (wrapWorksheet(change.getText), Some (toUnwrappedPosition _))
218
+ else (change.getText, None )
219
+
220
+ val diags = driver.run(uri, text)
221
+
222
+ client.publishDiagnostics(new PublishDiagnosticsParams (
223
+ document.getUri,
224
+ diags.flatMap(diagnostic(_, positionMapper)).asJava))
225
+ }
220
226
}
221
227
222
228
override def didClose (params : DidCloseTextDocumentParams ): Unit = thisServer.synchronized {
0 commit comments