File tree Expand file tree Collapse file tree 1 file changed +14
-10
lines changed Expand file tree Collapse file tree 1 file changed +14
-10
lines changed Original file line number Diff line number Diff line change @@ -173,17 +173,21 @@ void CodeEditor::keyPressEvent(QKeyEvent* e)
173173 }
174174 break ;
175175 case Qt::Key_Tab:
176- SelectLineMarginBlock ();
177- {
178- QString text (" " );
179- QStringList lines = this ->textCursor ().selection ().toPlainText ().split (QRegExp (" \n |\r\n |\r " ));
180- foreach (QString line, lines) {
181- text.append (" " );
182- text.append (line);
183- text.append (" \n " );
176+ if (this ->textCursor ().hasSelection ()) {
177+ SelectLineMarginBlock ();
178+ {
179+ QString text (" " );
180+ QStringList lines = this ->textCursor ().selection ().toPlainText ().split (QRegExp (" \n |\r\n |\r " ));
181+ foreach (QString line, lines) {
182+ text.append (" " );
183+ text.append (line);
184+ text.append (" \n " );
185+ }
186+ text.truncate (text.length () - 1 );
187+ this ->textCursor ().insertText (text);
184188 }
185- text. truncate (text. length () - 1 );
186- this ->textCursor (). insertText (text );
189+ } else {
190+ this ->insertPlainText ( " " );
187191 }
188192 break ;
189193 case Qt::Key_Enter:
You can’t perform that action at this time.
0 commit comments