Skip to content

Commit 42a7a0d

Browse files
committed
feat: Pressing home-key move at the beg of line
1 parent 3271969 commit 42a7a0d

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/internal/QCodeEditor.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -843,6 +843,17 @@ void QCodeEditor::keyPressEvent(QKeyEvent *e)
843843
return;
844844
}
845845

846+
if (e->matches(QKeySequence::MoveToStartOfLine))
847+
{
848+
auto cursor = textCursor();
849+
cursor.movePosition(QTextCursor::StartOfLine);
850+
auto line = cursor.block().text();
851+
QString startingSpaces = QRegularExpression("^\\s*").match(line).captured();
852+
cursor.movePosition(QTextCursor::Right, QTextCursor::MoveAnchor, startingSpaces.count());
853+
setTextCursor(cursor);
854+
return;
855+
}
856+
846857
QTextEdit::keyPressEvent(e);
847858
}
848859

0 commit comments

Comments
 (0)