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
Marco Bubke
flatpak-qt-creator
Commits
530016aa
Commit
530016aa
authored
Jun 04, 2010
by
mae
Browse files
Fix cursor positioning for up/down after backspace
Reviewed-by: Roberto Raggi
parent
63ef0d36
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/plugins/texteditor/basetexteditor.cpp
View file @
530016aa
...
...
@@ -1171,7 +1171,6 @@ void BaseTextEditor::keyPressEvent(QKeyEvent *e)
break
;
pos
=
cpos
;
}
setTextCursor
(
textCursor
());
// make cursor visible
return
;
}
else
switch
(
e
->
key
())
{
...
...
@@ -1215,7 +1214,6 @@ void BaseTextEditor::keyPressEvent(QKeyEvent *e)
|
Qt
::
MetaModifier
))
==
Qt
::
NoModifier
&&
!
textCursor
().
hasSelection
())
{
handleBackspaceKey
();
setTextCursor
(
textCursor
());
// make cursor visible
e
->
accept
();
return
;
}
...
...
@@ -3723,6 +3721,8 @@ void BaseTextEditor::handleHomeKey(bool anchor)
setTextCursor
(
cursor
);
}
#define SET_AND_RETURN(cursor) setTextCursor(cursor); return // make cursor visible and reset vertical x movement
void
BaseTextEditor
::
handleBackspaceKey
()
{
QTextCursor
cursor
=
textCursor
();
...
...
@@ -3742,7 +3742,7 @@ void BaseTextEditor::handleBackspaceKey()
if
(
!
tabSettings
.
m_smartBackspace
)
{
cursor
.
deletePreviousChar
();
return
;
SET_AND_RETURN
(
cursor
)
;
}
QTextBlock
currentBlock
=
cursor
.
block
();
...
...
@@ -3750,7 +3750,7 @@ void BaseTextEditor::handleBackspaceKey()
const
QString
blockText
=
currentBlock
.
text
();
if
(
cursor
.
atBlockStart
()
||
tabSettings
.
firstNonSpace
(
blockText
)
<
positionInBlock
)
{
cursor
.
deletePreviousChar
();
return
;
SET_AND_RETURN
(
cursor
)
;
}
int
previousIndent
=
0
;
...
...
@@ -3769,10 +3769,11 @@ void BaseTextEditor::handleBackspaceKey()
cursor
.
setPosition
(
currentBlock
.
position
(),
QTextCursor
::
KeepAnchor
);
cursor
.
insertText
(
tabSettings
.
indentationString
(
previousNonEmptyBlockText
));
cursor
.
endEditBlock
();
return
;
SET_AND_RETURN
(
cursor
)
;
}
}
cursor
.
deletePreviousChar
();
SET_AND_RETURN
(
cursor
);
}
void
BaseTextEditor
::
wheelEvent
(
QWheelEvent
*
e
)
...
...
Write
Preview
Supports
Markdown
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