Skip to content
Snippets Groups Projects
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: default avatarDavid Schulz <david.schulz@qt.io>
parent 7643b2cc
Branches
Tags
No related merge requests found
...@@ -138,10 +138,13 @@ void Uncrustify::formatSelectedText() ...@@ -138,10 +138,13 @@ void Uncrustify::formatSelectedText()
if (tc.hasSelection()) { if (tc.hasSelection()) {
// Extend selection to full lines // Extend selection to full lines
const int posSelectionEnd = tc.selectionEnd(); const int posSelectionEnd = tc.selectionEnd();
tc.setPosition(tc.selectionStart());
tc.movePosition(QTextCursor::StartOfLine); tc.movePosition(QTextCursor::StartOfLine);
const int startPos = tc.position(); const int startPos = tc.position();
tc.setPosition(posSelectionEnd); 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(); const int endPos = tc.position();
m_beautifierPlugin->formatCurrentFile(command(cfgFileName, true), startPos, endPos); m_beautifierPlugin->formatCurrentFile(command(cfgFileName, true), startPos, endPos);
} else if (m_settings->formatEntireFileFallback()) { } else if (m_settings->formatEntireFileFallback()) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment