77#include < Qsci/qscicommand.h>
88
99#include < QShortcut>
10- #include < QRegExp >
10+ #include < QRegularExpression >
1111
1212SqlUiLexer* SqlTextEdit::sqlLexer = nullptr ;
1313
@@ -104,16 +104,19 @@ void SqlTextEdit::toggleBlockComment()
104104 if (!hasSelectedText ()) {
105105 getCursorPosition (&lineFrom, &indexFrom);
106106
107+ indexTo = text (lineFrom).length ();
108+
107109 // Windows lines requires an adjustment, otherwise the selection would
108110 // end in the next line.
109- indexTo = text (lineFrom).endsWith (" \r\n " ) ? lineLength (lineFrom)-1 : lineLength (lineFrom);
111+ if (text (lineFrom).endsWith (" \r\n " ))
112+ indexTo--;
110113
111114 setSelection (lineFrom, 0 , lineFrom, indexTo);
112115 }
113116
114117 getSelection (&lineFrom, &indexFrom, &lineTo, &indexTo);
115118
116- bool uncomment = text (lineFrom).contains (QRegExp (" ^[ \t ]*--" ));
119+ bool uncomment = text (lineFrom).contains (QRegularExpression (" ^[ \t ]*--" ));
117120
118121 // If the selection ends before the first character of a line, don't
119122 // take this line into account for un/commenting.
@@ -129,11 +132,13 @@ void SqlTextEdit::toggleBlockComment()
129132 QString lineText = text (line);
130133
131134 if (uncomment)
132- lineText.replace (QRegExp (" ^([ \t ]*)-- ?" ), " \\ 1" );
135+ lineText.replace (QRegularExpression (" ^([ \t ]*)-- ?" ), " \\ 1" );
133136 else
134- lineText.replace (QRegExp (" ^" ), " -- " );
137+ lineText.replace (QRegularExpression (" ^" ), " -- " );
135138
136- indexTo = lineText.endsWith (" \r\n " ) ? lineLength (line)-1 : lineLength (line);
139+ indexTo = text (line).length ();
140+ if (lineText.endsWith (" \r\n " ))
141+ indexTo--;
137142
138143 setSelection (line, 0 , line, indexTo);
139144 replaceSelectedText (lineText);
0 commit comments