Skip to content

Commit fc44a0b

Browse files
committed
fix: Fix indentation when pressing enter with cursor in the indentation
The bug: When it's: ``` <space><cursor><space> ``` And you press enter, it will become: ``` <space> <space><space><cursor><space> ``` But the expected behavior is: ``` <space> <space><cursor><space> ``` This commit fixes it.
1 parent 13376c5 commit fc44a0b

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/internal/QCodeEditor.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -712,6 +712,11 @@ void QCodeEditor::keyPressEvent(QKeyEvent *e)
712712
moveCursor(QTextCursor::EndOfBlock);
713713
return;
714714
}
715+
else
716+
{
717+
indentationSpaces = indentationSpaces.left(textCursor().columnNumber());
718+
}
719+
715720
insertPlainText("\n" + indentationSpaces);
716721
return;
717722
}

0 commit comments

Comments
 (0)