File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed
Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -656,6 +656,31 @@ void QCodeEditor::keyPressEvent(QKeyEvent *e)
656656 return ;
657657 }
658658 }
659+
660+ if (textCursor ().columnNumber () <= indentationSpaces.length () && textCursor ().columnNumber () >= 1 &&
661+ !m_tabReplace.isEmpty ())
662+ {
663+ auto cursor = textCursor ();
664+ int realColumn = 0 , newIndentLength = 0 ;
665+ for (int i = 0 ; i < cursor.columnNumber (); ++i)
666+ {
667+ if (indentationSpaces[i] != ' \t ' )
668+ ++realColumn;
669+ else
670+ {
671+ realColumn =
672+ (realColumn + m_tabReplace.length ()) / m_tabReplace.length () * m_tabReplace.length ();
673+ }
674+ if (realColumn % m_tabReplace.length () == 0 && i < cursor.columnNumber () - 1 )
675+ {
676+ newIndentLength = i + 1 ;
677+ }
678+ }
679+ cursor.movePosition (QTextCursor::PreviousCharacter, QTextCursor::KeepAnchor,
680+ cursor.columnNumber () - newIndentLength);
681+ cursor.insertText (" " );
682+ return ;
683+ }
659684 }
660685
661686 if (m_autoParentheses)
You can’t perform that action at this time.
0 commit comments