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
373bfb05
Commit
373bfb05
authored
Jun 10, 2010
by
Christian Kamm
Browse files
QmlJS: On completion, avoid adding : or . again if already present.
parent
4f6dc35a
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/plugins/qmljseditor/qmljscodecompletion.cpp
View file @
373bfb05
...
...
@@ -902,7 +902,25 @@ void CodeCompletion::complete(const TextEditor::CompletionItem &item)
}
}
const
int
length
=
m_editor
->
position
()
-
m_startPosition
;
QString
replacableChars
;
if
(
toInsert
.
endsWith
(
QLatin1String
(
": "
)))
replacableChars
=
QLatin1String
(
": "
);
else
if
(
toInsert
.
endsWith
(
QLatin1String
(
"."
)))
replacableChars
=
QLatin1String
(
"."
);
int
replacedLength
=
0
;
// Avoid inserting characters that are already there
for
(
int
i
=
0
;
i
<
replacableChars
.
length
();
++
i
)
{
const
QChar
a
=
replacableChars
.
at
(
i
);
const
QChar
b
=
m_editor
->
characterAt
(
m_editor
->
position
()
+
i
);
if
(
a
==
b
)
++
replacedLength
;
else
break
;
}
const
int
length
=
m_editor
->
position
()
-
m_startPosition
+
replacedLength
;
m_editor
->
setCurPos
(
m_startPosition
);
m_editor
->
replace
(
length
,
toInsert
);
...
...
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