aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/beautifier
diff options
context:
space:
mode:
authorViktor Kireev <vitech-job@yandex.ru>2017-10-03 19:17:02 +0300
committerViktor Kireev <vitech-job@yandex.ru>2017-10-13 07:47:52 +0000
commit02b5426b8e223baf6815de936bccc99d44d74e3c (patch)
treef38226f4303264c8058ddb2f30c07ed07e562c12 /src/plugins/beautifier
parent7643b2ccdc9999f181d235a70172cad0ddae7967 (diff)
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 <david.schulz@qt.io>
Diffstat (limited to 'src/plugins/beautifier')
-rw-r--r--src/plugins/beautifier/uncrustify/uncrustify.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/plugins/beautifier/uncrustify/uncrustify.cpp b/src/plugins/beautifier/uncrustify/uncrustify.cpp
index b47672bc5e..0f00d5fc69 100644
--- a/src/plugins/beautifier/uncrustify/uncrustify.cpp
+++ b/src/plugins/beautifier/uncrustify/uncrustify.cpp
@@ -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()) {