Skip to content
GitLab
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
312509fc
Commit
312509fc
authored
Jul 06, 2010
by
hjk
Browse files
fakevim: fix backspace in the presence of physical tabs
(cherry picked from commit 2b40e2906fc070c6253a84c0ca507ff0db912f73)
parent
cd433a52
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/plugins/fakevim/fakevimhandler.cpp
View file @
312509fc
...
...
@@ -232,6 +232,11 @@ struct Column
int
logical
;
// Column on screen.
};
QDebug
operator
<<
(
QDebug
ts
,
const
Column
&
col
)
{
return
ts
<<
"(p: "
<<
col
.
physical
<<
", l: "
<<
col
.
logical
<<
")"
;
}
struct
CursorPosition
{
// for jump history
...
...
@@ -2619,11 +2624,11 @@ EventResult FakeVimHandler::Private::handleInsertMode(const Input &input)
if
(
col
.
logical
<=
ind
.
logical
&&
col
.
logical
&&
startsWithWhitespace
(
data
,
col
.
physical
))
{
const
int
ts
=
config
(
ConfigTabStop
).
toInt
();
const
int
new
co
l
=
col
.
logical
-
1
-
(
col
.
logical
-
1
)
%
ts
;
data
.
remove
(
0
,
col
.
physica
l
);
setLineContents
(
line
,
tabExpand
(
newcol
).
append
(
data
));
const
int
newl
=
col
.
logical
-
1
-
(
col
.
logical
-
1
)
%
ts
;
const
QString
prefix
=
tabExpand
(
new
l
);
setLineContents
(
line
,
prefix
+
data
.
mid
(
col
.
physical
));
moveToStartOfLine
();
moveRight
(
newcol
);
moveRight
(
prefix
.
size
()
);
m_lastInsertion
.
clear
();
// FIXME
}
else
{
m_tc
.
deletePreviousChar
();
...
...
@@ -4303,10 +4308,12 @@ void FakeVimHandler::Private::setLineContents(int line, const QString &contents)
{
QTextBlock
block
=
m_tc
.
document
()
->
findBlockByNumber
(
line
-
1
);
QTextCursor
tc
=
m_tc
;
tc
.
setPosition
(
block
.
position
());
tc
.
setPosition
(
block
.
position
()
+
block
.
length
()
-
1
,
KeepAnchor
);
const
int
begin
=
block
.
position
();
const
int
len
=
block
.
length
();
tc
.
setPosition
(
begin
);
tc
.
setPosition
(
begin
+
len
-
1
,
KeepAnchor
);
tc
.
removeSelectedText
();
fixMarks
(
b
lock
.
position
(),
block
.
length
()
-
contents
.
size
());
fixMarks
(
b
egin
,
contents
.
size
()
+
1
-
len
);
tc
.
insertText
(
contents
);
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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