Skip to content

Commit

Permalink
Merge pull request apache#4728 from matthiasblaesing/lsp_insert
Browse files Browse the repository at this point in the history
LSP Client: Use full complete item to complete, not just the missing suffix
  • Loading branch information
matthiasblaesing authored Nov 25, 2022
2 parents 991f962 + b4a0990 commit e2468f0
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,14 @@ private void commit(String appendText) {
toAdd = i.getLabel();
}
int[] identSpan = Utilities.getIdentifierBlock((BaseDocument) doc, caretOffset);
String printSuffix = toAdd.substring(identSpan != null ? caretOffset - identSpan[0] : 0);
doc.insertString(caretOffset, printSuffix, null);
endPos = caretOffset + printSuffix.length();
if (identSpan != null) {
doc.remove(identSpan[0], identSpan[1] - identSpan[0]);
doc.insertString(identSpan[0], toAdd, null);
endPos = identSpan[0] + toAdd.length();
} else {
doc.insertString(caretOffset, toAdd, null);
endPos = caretOffset + toAdd.length();
}
}
doc.insertString(endPos, appendText, null);
} catch (BadLocationException ex) {
Expand Down

0 comments on commit e2468f0

Please sign in to comment.