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
19f4466e
Commit
19f4466e
authored
Sep 16, 2009
by
Thorbjørn Lindeijer
Browse files
Tweaks to skipping of closing parenthesis and quote characters
Done with mae.
parent
b2235b5c
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/plugins/texteditor/basetexteditor.cpp
View file @
19f4466e
...
...
@@ -1074,11 +1074,13 @@ void BaseTextEditor::keyPressEvent(QKeyEvent *e)
QString
autoText
;
if
(
d
->
m_autoParenthesesEnabled
&&
d
->
m_document
->
tabSettings
().
m_autoParentheses
)
{
QChar
lookAhead
=
characterAt
(
cursor
.
position
());
foreach
(
QChar
c
,
text
)
{
QChar
close
;
if
(
c
==
QLatin1Char
(
'('
))
close
=
QLatin1Char
(
')'
);
else
if
(
c
==
QLatin1Char
(
'['
))
if
(
c
==
QLatin1Char
(
'('
))
{
if
(
!
lookAhead
.
isLetterOrNumber
()
&&
lookAhead
!=
c
)
close
=
QLatin1Char
(
')'
);
}
else
if
(
c
==
QLatin1Char
(
'['
))
close
=
QLatin1Char
(
']'
);
else
if
(
c
==
QLatin1Char
(
'\"'
))
close
=
c
;
...
...
@@ -1088,15 +1090,24 @@ void BaseTextEditor::keyPressEvent(QKeyEvent *e)
autoText
+=
close
;
}
bool
skip
=
false
;
QChar
first
=
text
.
at
(
0
);
if
(
first
==
QLatin1Char
(
')'
)
||
first
==
QLatin1Char
(
']'
))
{
if
(
first
==
characterAt
(
cursor
.
position
()))
{
int
pos
=
cursor
.
position
();
cursor
.
setPosition
(
pos
+
1
);
cursor
.
setPosition
(
pos
,
QTextCursor
::
KeepAnchor
);
if
(
first
==
QLatin1Char
(
')'
))
{
skip
=
(
first
==
lookAhead
);
}
else
if
(
first
==
QLatin1Char
(
']'
))
{
skip
=
(
first
==
lookAhead
);
}
else
if
(
first
==
QLatin1Char
(
'\"'
)
||
first
==
QLatin1Char
(
'\''
))
{
if
(
first
==
lookAhead
)
{
QChar
lookBehind
=
characterAt
(
cursor
.
position
()
-
1
);
skip
=
(
lookBehind
!=
'\\'
);
}
}
if
(
skip
)
{
int
pos
=
cursor
.
position
();
cursor
.
setPosition
(
pos
+
1
);
cursor
.
setPosition
(
pos
,
QTextCursor
::
KeepAnchor
);
}
}
QChar
electricChar
;
if
(
d
->
m_document
->
tabSettings
().
m_autoIndent
)
{
...
...
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