GH-1153: due to the new insert text mode setting <as-is>, we do not need to deal with client-side magic indentation anymore

This commit is contained in:
Martin Lippert
2023-12-01 13:18:22 +01:00
parent ae68b8eef8
commit 37b067849b

View File

@@ -458,17 +458,17 @@ public class Editor {
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);