Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Tobias Hunger
qt-creator
Commits
dc40d764
Commit
dc40d764
authored
Oct 01, 2009
by
mae
Browse files
small refactoring to avoid dependency on a current qt fix
parent
b6ec2853
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/plugins/texteditor/basetexteditor.cpp
View file @
dc40d764
...
...
@@ -4624,18 +4624,10 @@ void BaseTextEditor::insertFromMimeData(const QMimeData *source)
||
text
.
endsWith
(
QChar
::
ParagraphSeparator
)
||
text
.
endsWith
(
QLatin1Char
(
'\r'
)));
QTextCursor
unnecessaryWhitespace
;
if
(
hasFinalNewline
)
{
// since we'll add a final newline, preserve current line's indentation
if
(
hasFinalNewline
)
// since we'll add a final newline, preserve current line's indentation
cursor
.
setPosition
(
cursor
.
block
().
position
());
}
else
{
unnecessaryWhitespace
=
cursor
;
int
pos
=
cursor
.
position
();
// construct the selection in a way that it will not expand when the cursor position moves
unnecessaryWhitespace
.
movePosition
(
QTextCursor
::
StartOfBlock
);
unnecessaryWhitespace
.
setPosition
(
pos
,
QTextCursor
::
KeepAnchor
);
}
int
cursorPosition
=
cursor
.
position
();
cursor
.
insertText
(
text
);
int
reindentBlockEnd
=
cursor
.
blockNumber
()
-
(
hasFinalNewline
?
1
:
0
);
...
...
@@ -4643,8 +4635,12 @@ void BaseTextEditor::insertFromMimeData(const QMimeData *source)
if
(
reindentBlockStart
<
reindentBlockEnd
||
(
reindentBlockStart
==
reindentBlockEnd
&&
(
!
insertAtBeginningOfLine
||
hasFinalNewline
)))
{
if
(
insertAtBeginningOfLine
&&
!
hasFinalNewline
)
if
(
insertAtBeginningOfLine
&&
!
hasFinalNewline
)
{
QTextCursor
unnecessaryWhitespace
=
cursor
;
unnecessaryWhitespace
.
setPosition
(
cursorPosition
);
unnecessaryWhitespace
.
movePosition
(
QTextCursor
::
StartOfBlock
,
QTextCursor
::
KeepAnchor
);
unnecessaryWhitespace
.
removeSelectedText
();
}
QTextCursor
c
=
cursor
;
c
.
setPosition
(
cursor
.
document
()
->
findBlockByNumber
(
reindentBlockStart
).
position
());
c
.
setPosition
(
cursor
.
document
()
->
findBlockByNumber
(
reindentBlockEnd
).
position
(),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment