Skip to content

Commit

Permalink
GH-1153: due to the new insert text mode setting <as-is>, we do not n…
Browse files Browse the repository at this point in the history
…eed to deal with client-side magic indentation anymore
  • Loading branch information
martinlippert committed Dec 1, 2023
1 parent ae68b8e commit 37b0678
Showing 1 changed file with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -458,17 +458,17 @@ public void apply(CompletionItem completion) throws Exception {
String replaceWith = edit.getLeft().getNewText();
int cursorReplaceOffset = 0;

if (!Boolean.getBoolean("lsp.completions.indentation.enable")) {
//Apply indentfix, this is magic vscode seems to apply to edits returned by language server. So our harness has to
// mimick that behavior. See https://github.com/Microsoft/language-server-protocol/issues/83
int referenceLine = edit.getLeft().getRange().getStart().getLine();
int cursorOffset = edit.getLeft().getRange().getStart().getCharacter();
String referenceIndent = doc.getLineIndentString(referenceLine);
if (cursorOffset<referenceIndent.length()) {
referenceIndent = referenceIndent.substring(0, cursorOffset);
}
replaceWith = replaceWith.replaceAll("\\n", "\n"+referenceIndent);
}
// if (!Boolean.getBoolean("lsp.completions.indentation.enable")) {
// //Apply indentfix, this is magic vscode seems to apply to edits returned by language server. So our harness has to
// // mimick that behavior. See https://github.com/Microsoft/language-server-protocol/issues/83
// int referenceLine = edit.getLeft().getRange().getStart().getLine();
// int cursorOffset = edit.getLeft().getRange().getStart().getCharacter();
// String referenceIndent = doc.getLineIndentString(referenceLine);
// if (cursorOffset<referenceIndent.length()) {
// referenceIndent = referenceIndent.substring(0, cursorOffset);
// }
// replaceWith = replaceWith.replaceAll("\\n", "\n"+referenceIndent);
// }

// Replace the cursor string
cursorReplaceOffset = replaceWith.indexOf(VS_CODE_CURSOR_MARKER);
Expand Down

0 comments on commit 37b0678

Please sign in to comment.