Skip to content

Commit

Permalink
Fix the document out-of-sync due to multi threads changing the curren…
Browse files Browse the repository at this point in the history
…t workingcopy buffer
  • Loading branch information
testforstephen committed Nov 21, 2023
1 parent 45aeb8d commit 80c47a7
Showing 1 changed file with 1 addition and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,6 @@ public static String[] getStaticImportFavorites(ICompilationUnit cu, final Strin
dummyCU.append("\n}\n }"); //$NON-NLS-1$

ICompilationUnit newCU= null;
String contents = cu.getBuffer().getContents();
try {
newCU= cu.getWorkingCopy(null);
newCU.getBuffer().setContents(dummyCU.toString());
Expand Down Expand Up @@ -304,13 +303,9 @@ public void accept(CompletionProposal proposal) {
requestor.setFavoriteReferences(favorites);

newCU.codeComplete(offset, requestor);
// if cu is working copy, we should restore the contents saved previously.
if (cu.isWorkingCopy()) {
cu.getBuffer().setContents(contents);
}
return result.toArray(new String[result.size()]);
} finally {
if (newCU != null && !cu.isWorkingCopy()) {
if (newCU != null) {
newCU.discardWorkingCopy();
}
}
Expand Down

0 comments on commit 80c47a7

Please sign in to comment.