Skip to content

Commit

Permalink
Autocompletion overwrites following characters
Browse files Browse the repository at this point in the history
Signed-off-by: Snjezana Peco <[email protected]>
  • Loading branch information
snjeza authored and fbricon committed Nov 1, 2017
1 parent 12b451f commit 1716e00
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,16 +98,19 @@ public boolean belongsTo(Object family) {
}

private void triggerValidation(ICompilationUnit cu) throws JavaModelException {
triggerValidation(cu, 400);
}

private void triggerValidation(ICompilationUnit cu, long delay) throws JavaModelException {
synchronized (toReconcile) {
toReconcile.add(cu);
}
if (validationTimer != null) {
validationTimer.cancel();
validationTimer.schedule(400);
validationTimer.schedule(delay);
} else {
performValidation(new NullProgressMonitor());
}

}

private IStatus performValidation(IProgressMonitor monitor) throws JavaModelException {
Expand Down Expand Up @@ -282,7 +285,7 @@ public void handleChanged(DidChangeTextDocumentParams params) {
IDocument document = JsonRpcHelpers.toDocument(unit.getBuffer());
edit.apply(document, TextEdit.NONE);
}
triggerValidation(unit);
triggerValidation(unit, 0);
} catch (JavaModelException | MalformedTreeException | BadLocationException e) {
JavaLanguageServerPlugin.logException("Error while handling document change", e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,22 @@ public void didOpen(DidOpenTextDocumentParams params) {
@Override
public void didChange(DidChangeTextDocumentParams params) {
logInfo(">> document/didChange");
try {
Job[] jobs = Job.getJobManager().find(DocumentLifeCycleHandler.DOCUMENT_LIFE_CYCLE_JOBS);
boolean wait = jobs.length > 0;
long start = System.currentTimeMillis();
while (wait) {
jobs = Job.getJobManager().find(DocumentLifeCycleHandler.DOCUMENT_LIFE_CYCLE_JOBS);
wait = (System.currentTimeMillis() - start) < 1000 && jobs.length > 0;
if (wait) {
Thread.sleep(100);
}
}
} catch (OperationCanceledException ignorable) {
// No need to pollute logs when query is cancelled
} catch (InterruptedException e) {
JavaLanguageServerPlugin.logException(e.getMessage(), e);
}
documentLifeCycleHandler.didChange(params);
}

Expand Down

0 comments on commit 1716e00

Please sign in to comment.