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
7c829447
Commit
7c829447
authored
May 26, 2010
by
mae
Browse files
Fix qml autocompletion on Enter
Only insert necessary newlines Reviewed-by: thorbjorn Task-number: QTCREATORBUG-1476
parent
a45bfdc4
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/plugins/qmljseditor/qmljseditor.cpp
View file @
7c829447
...
...
@@ -1225,9 +1225,33 @@ QString QmlJSTextEditor::insertMatchingBrace(const QTextCursor &tc, const QStrin
return
QString
();
}
QString
QmlJSTextEditor
::
insertParagraphSeparator
(
const
QTextCursor
&
)
const
static
bool
shouldInsertNewline
(
const
QTextCursor
&
tc
)
{
return
QLatin1String
(
"}
\n
"
);
QTextDocument
*
doc
=
tc
.
document
();
int
pos
=
tc
.
selectionEnd
();
// count the number of empty lines.
int
newlines
=
0
;
for
(
int
e
=
doc
->
characterCount
();
pos
!=
e
;
++
pos
)
{
const
QChar
ch
=
doc
->
characterAt
(
pos
);
if
(
!
ch
.
isSpace
())
break
;
else
if
(
ch
==
QChar
::
ParagraphSeparator
)
++
newlines
;
}
if
(
newlines
<=
1
&&
doc
->
characterAt
(
pos
)
!=
QLatin1Char
(
'}'
))
return
true
;
return
false
;
}
QString
QmlJSTextEditor
::
insertParagraphSeparator
(
const
QTextCursor
&
tc
)
const
{
if
(
shouldInsertNewline
(
tc
))
return
QLatin1String
(
"}
\n
"
);
return
QLatin1String
(
"}"
);
}
void
QmlJSTextEditor
::
forceSemanticRehighlight
()
...
...
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