mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-01-20 02:50:46 -06:00
Adapt to QScintilla behaviour with Windows line terminator
QScintilla is returning strings with text(line) with line terminator and they are also counted by lineLength, so the Windows version has to substract one for setSelection. This solves various problems resulting in characters being removed at the beginning of lines when commenting or uncommenting blocks of code with Windows line terminators.
This commit is contained in:
@@ -104,12 +104,15 @@ void SqlTextEdit::toggleBlockComment()
|
||||
// or uncommented, and replace the line text.
|
||||
for (int line=lineFrom; line<lineTo; line++) {
|
||||
QString lineText = text(line);
|
||||
|
||||
if (uncomment)
|
||||
lineText.replace(QRegExp("^([ \t]*)-- ?"), "\\1");
|
||||
else
|
||||
lineText.replace(QRegExp("^"), "-- ");
|
||||
|
||||
setSelection(line, 0, line, lineLength(line));
|
||||
indexTo = lineText.endsWith("\r\n") ? lineLength(line)-1 : lineLength(line);
|
||||
|
||||
setSelection(line, 0, line, indexTo);
|
||||
replaceSelectedText(lineText);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user