Skip to content

Commit

Permalink
Merge pull request #592 from StarkZhidian/p/hiro/fix/fix_indent_error…
Browse files Browse the repository at this point in the history
…_when_EnterAction_object_reuse_0516

--bugfix=fix indent size error when EnterAction object reuse.
  • Loading branch information
Rosemoe authored May 17, 2024
2 parents 909ca14 + 372a4e9 commit ab61ec9
Showing 1 changed file with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -414,24 +414,27 @@ public CompleteEnterAction getEnterAction(final Content content, final CharPosit
return null;
}

final EnterAction.IndentAction indentAction = enterResult.indentAction;
String appendText = enterResult.appendText;
final Integer removeText = enterResult.removeText;
// Here we add `\t` to appendText first because enterAction is leveraging
// appendText and removeText to change indentation.
if (enterResult.appendText == null) {
if (enterResult.indentAction == EnterAction.IndentAction.Indent || enterResult.indentAction == EnterAction.IndentAction.IndentOutdent) {
enterResult.appendText = "\t";
if (appendText == null) {
if (indentAction == EnterAction.IndentAction.Indent
|| indentAction == EnterAction.IndentAction.IndentOutdent) {
appendText = "\t";
} else {
enterResult.appendText = "";
appendText = "";
}
} else if (enterResult.indentAction == EnterAction.IndentAction.Indent) {
enterResult.appendText = "\t" + enterResult.appendText;
} else if (indentAction == EnterAction.IndentAction.Indent) {
appendText = "\t" + appendText;
}

final var removeText = enterResult.removeText;
if (removeText != null) {
indentation = indentation.substring(0, indentation.length() - removeText);
}

return new CompleteEnterAction(enterResult.indentAction, enterResult.appendText, enterResult.removeText, indentation);
return new CompleteEnterAction(indentAction, appendText, removeText, indentation);

}

Expand Down

0 comments on commit ab61ec9

Please sign in to comment.