Commit 02b5426b authored by Viktor Kireev's avatar Viktor Kireev
Browse files

Beautifier: Fix text selection for the Uncrustify



Extension of the selection of the text to full lines
does not work correctly if the selection is performed
from the top to the bottom.

Change-Id: I13a1bf9d6e92ebbbfd4f8190fb626dd3aca74686
Reviewed-by: David Schulz's avatarDavid Schulz <david.schulz@qt.io>
parent 7643b2cc
......@@ -138,10 +138,13 @@ void Uncrustify::formatSelectedText()
if (tc.hasSelection()) {
// Extend selection to full lines
const int posSelectionEnd = tc.selectionEnd();
tc.setPosition(tc.selectionStart());
tc.movePosition(QTextCursor::StartOfLine);
const int startPos = tc.position();
tc.setPosition(posSelectionEnd);
tc.movePosition(QTextCursor::EndOfLine);
// Don't extend the selection if the cursor is at the start of the line
if (tc.positionInBlock() > 0)
tc.movePosition(QTextCursor::EndOfLine);
const int endPos = tc.position();
m_beautifierPlugin->formatCurrentFile(command(cfgFileName, true), startPos, endPos);
} else if (m_settings->formatEntireFileFallback()) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment