Skip to content

Commit

Permalink
Derives which line to unset vertical indent during typing mismatch (#250
Browse files Browse the repository at this point in the history
)
  • Loading branch information
dingfeli authored Nov 21, 2024
1 parent 4c62409 commit ef66134
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,7 @@ public void beforeRemoval() {
currentOffset);
int lineNumber = doc.getLineOfOffset(expandedCurrentOffset);
int startLineOffset = doc.getLineOffset(lineNumber);
int invocationOffset = session.getInvocationOffset();
int curLineInDoc = widget.getLineAtOffset(invocationOffset);
int curLineInDoc = widget.getLineAtOffset(currentOffset);
int lineIdx = expandedCurrentOffset - startLineOffset;
String contentInLine = widget.getLine(curLineInDoc) + widget.getLineDelimiter();
String currentRightCtx = "\n";
Expand Down Expand Up @@ -323,9 +322,13 @@ public void documentChanged(final DocumentEvent event) {
boolean isOutOfBounds = distanceTraversed + input.length() >= currentSuggestion.length()
|| distanceTraversed < 0;
if (isOutOfBounds || !isInputAMatch(currentSuggestion, distanceTraversed, input)) {
distanceTraversed++;
session.transitionToDecisionMade();
distanceTraversed += input.length();
event.getDocument().removeDocumentListener(this);
StyledText widget = session.getViewer().getTextWidget();
int caretLine = widget.getLineAtOffset(widget.getCaretOffset());
int linesOfInput = input.split(widget.getLineDelimiter()).length;
int lineToUnsetIndent = caretLine + linesOfInput;
session.transitionToDecisionMade(lineToUnsetIndent);
Display.getCurrent().asyncExec(() -> {
if (session.isActive()) {
session.end();
Expand Down

0 comments on commit ef66134

Please sign in to comment.