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
4133107a
Commit
4133107a
authored
Jun 02, 2009
by
hjk
Browse files
fakevim: remove old undo hack as QPlainTextEdit's own undo works well now.
parent
76f57c86
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/plugins/fakevim/fakevimhandler.cpp
View file @
4133107a
...
...
@@ -212,8 +212,6 @@ enum EventResult
EventPassedToCore
};
class
UndoBreaker
;
class
FakeVimHandler
::
Private
{
public:
...
...
@@ -229,7 +227,6 @@ public:
void
restoreWidget
();
friend
class
FakeVimHandler
;
friend
class
UndoBreaker
;
static
int
shift
(
int
key
)
{
return
key
+
32
;
}
static
int
control
(
int
key
)
{
return
key
+
256
;
}
...
...
@@ -354,7 +351,6 @@ public:
void
undo
();
void
redo
();
QMap
<
int
,
int
>
m_undoCursorPosition
;
// revision -> position
bool
m_needMoreUndo
;
// extra data for '.'
void
replay
(
const
QString
&
text
,
int
count
);
...
...
@@ -2412,10 +2408,7 @@ void FakeVimHandler::Private::undo()
{
int
current
=
m_tc
.
document
()
->
revision
();
m_tc
.
endEditBlock
();
m_needMoreUndo
=
false
;
EDITOR
(
undo
());
if
(
m_needMoreUndo
)
EDITOR
(
undo
());
m_tc
.
beginEditBlock
();
int
rev
=
m_tc
.
document
()
->
revision
();
if
(
current
==
rev
)
...
...
@@ -2430,10 +2423,7 @@ void FakeVimHandler::Private::redo()
{
int
current
=
m_tc
.
document
()
->
revision
();
m_tc
.
endEditBlock
();
m_needMoreUndo
=
false
;
EDITOR
(
redo
());
if
(
m_needMoreUndo
)
EDITOR
(
redo
());
m_tc
.
beginEditBlock
();
int
rev
=
m_tc
.
document
()
->
revision
();
if
(
rev
==
current
)
...
...
@@ -2487,20 +2477,9 @@ void FakeVimHandler::Private::recordJump()
UNDO_DEBUG
(
"jumps: "
<<
m_jumpListUndo
);
}
class
UndoBreaker
:
public
QAbstractUndoItem
{
public:
UndoBreaker
(
FakeVimHandler
::
Private
*
doc
)
:
m_doc
(
doc
)
{}
void
undo
()
{
m_doc
->
m_needMoreUndo
=
true
;
}
void
redo
()
{
m_doc
->
m_needMoreUndo
=
true
;
}
private:
FakeVimHandler
::
Private
*
m_doc
;
};
void
FakeVimHandler
::
Private
::
recordNewUndo
()
{
m_tc
.
endEditBlock
();
m_tc
.
document
()
->
appendUndoItem
(
new
UndoBreaker
(
this
));
m_tc
.
beginEditBlock
();
}
...
...
tests/auto/fakevim/main.cpp
View file @
4133107a
...
...
@@ -328,12 +328,18 @@ void tst_FakeVim::command_i()
// combine insertions
check
(
"i1"
+
escape
,
"@1"
+
lines
);
check
(
"i2"
+
escape
,
"@21"
+
lines
);
check
(
"i3"
+
escape
,
"@321"
+
lines
);
check
(
"u"
,
"@21"
+
lines
);
check
(
"u"
,
"@1"
+
lines
);
check
(
"u"
,
"@"
+
lines
);
check
(
"ia"
+
escape
,
"@a"
+
lines
);
check
(
"ibx"
+
escape
,
"b@xa"
+
lines
);
check
(
"icyy"
+
escape
,
"bcy@yxa"
+
lines
);
return
;
// FIXME
check
(
"u"
,
"b@xa"
+
lines
);
check
(
"u"
,
"@a"
+
lines
);
// undo broken
return
;
// FIXME
checkEx
(
"redo"
,
"b@xa"
+
lines
);
check
(
"u"
,
"@a"
+
lines
);
check
(
"u"
,
"@"
+
lines
);
...
...
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