fix: avoid BadLocationException by not working on out of date documents#1444
Conversation
| long currentTimestamp = DocumentUtil.getDocumentModificationStamp(document); | ||
|
|
||
| if (currentTimestamp != timestamp) { | ||
| return; | ||
| } |
There was a problem hiding this comment.
This check is probably cheaper to perform, but since this method runs in a job, it is still possible that the document is changed after this check and we get a BadLocationException afterwards.
There was a problem hiding this comment.
@FlorianKroiss , you are right. What about now? I think we can check once before calculating the position to avoid creating potentially wrong highlights, and once more in the exception case to be really sure we do not have the exception because of a change in document.
We could also skip the first check, but I think it is very cheap, so better have it than sending outdated request to the LS.
There was a problem hiding this comment.
Yes that should work.
There was a problem hiding this comment.
@sebthom , I am merging this one and making it also part of the release with fixes.
e0881c9 to
cc7a838
Compare
Fixes #1439