-
Notifications
You must be signed in to change notification settings - Fork 65
Description
I was adding and removing characters at the end of the file, which caused the LS to send diagnostics, which in turn caused a BadLocationException when updating markers:
org.eclipse.jface.text.BadLocationException: 532
at org.eclipse.jface.text.TreeLineTracker.lineByOffset(TreeLineTracker.java:268)
at org.eclipse.jface.text.TreeLineTracker.getLineNumberOfOffset(TreeLineTracker.java:1112)
at org.eclipse.jface.text.AbstractLineTracker.getLineNumberOfOffset(AbstractLineTracker.java:246)
at org.eclipse.jface.text.AbstractDocument.getLineOfOffset(AbstractDocument.java:863)
at org.eclipse.core.internal.filebuffers.SynchronizableDocument.getLineOfOffset(SynchronizableDocument.java:429)
at org.eclipse.lsp4e.operations.diagnostics.LSPDiagnosticsToMarkers.computeMarkerAttributes(LSPDiagnosticsToMarkers.java:328)
at org.eclipse.lsp4e.operations.diagnostics.LSPDiagnosticsToMarkers$2.doRun(LSPDiagnosticsToMarkers.java:197)
at org.eclipse.lsp4e.operations.diagnostics.LSPDiagnosticsToMarkers$2.runInWorkspace(LSPDiagnosticsToMarkers.java:156)
at org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:43)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
More of general question, because I encountered a similar problem (#1439) recently:
I haven't really worked much with IDocument and friends, but I was wondering what is the proper way to handle asynchronous operations which try to access or change an IDocument outside of the UI thread? Locking the document in any way is probably not desirable, because this might lead to prolonged UI freezes. So should Jobs just repeatedly check if the document timestamp has changed and stop all work if it has changed?
Maybe someone with a deeper understanding of Eclipse document handling can give me some insights or point me in the right direction to some documentation?