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
da4fcd22
Commit
da4fcd22
authored
Sep 17, 2009
by
Roberto Raggi
Browse files
Pass the lookahead character to matching text.
parent
82b80b9e
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/libs/cplusplus/MatchingText.cpp
View file @
da4fcd22
...
...
@@ -71,10 +71,31 @@ static bool isCompleteCharLiteral(const BackwardsScanner &tk, int index, int sta
return
false
;
}
static
bool
shouldInsertMatchingText
(
const
QChar
&
lookAhead
)
{
if
(
lookAhead
.
isSpace
())
return
true
;
else
if
(
lookAhead
==
QLatin1Char
(
'{'
))
return
true
;
else
if
(
lookAhead
==
QLatin1Char
(
'}'
))
return
true
;
else
if
(
lookAhead
==
QLatin1Char
(
']'
))
return
true
;
else
if
(
lookAhead
==
QLatin1Char
(
')'
))
return
true
;
else
if
(
lookAhead
==
QLatin1Char
(
';'
))
return
true
;
else
if
(
lookAhead
==
QLatin1Char
(
','
))
return
true
;
return
false
;
}
MatchingText
::
MatchingText
()
{
}
QString
MatchingText
::
insertMatchingBrace
(
const
QTextCursor
&
cursor
,
const
QString
&
textToProcess
,
int
*
skippedChars
)
const
QString
MatchingText
::
insertMatchingBrace
(
const
QTextCursor
&
cursor
,
const
QString
&
textToProcess
,
const
QChar
&
la
,
int
*
skippedChars
)
const
{
*
skippedChars
=
0
;
...
...
@@ -101,7 +122,7 @@ QString MatchingText::insertMatchingBrace(const QTextCursor &cursor, const QStri
text
=
textToProcess
.
mid
(
*
skippedChars
);
}
if
(
text
.
isEmpty
())
if
(
text
.
isEmpty
()
||
!
shouldInsertMatchingText
(
la
)
)
return
QString
();
BackwardsScanner
tk
(
tc
,
textToProcess
.
left
(
*
skippedChars
),
MAX_NUM_LINES
);
...
...
src/libs/cplusplus/MatchingText.h
View file @
da4fcd22
...
...
@@ -41,7 +41,8 @@ class CPLUSPLUS_EXPORT MatchingText
public:
MatchingText
();
QString
insertMatchingBrace
(
const
QTextCursor
&
tc
,
const
QString
&
text
,
int
*
skippedChars
)
const
;
QString
insertMatchingBrace
(
const
QTextCursor
&
tc
,
const
QString
&
text
,
const
QChar
&
la
,
int
*
skippedChars
)
const
;
QString
insertParagraphSeparator
(
const
QTextCursor
&
tc
)
const
;
};
...
...
src/plugins/cppeditor/cppeditor.cpp
View file @
da4fcd22
...
...
@@ -1275,11 +1275,13 @@ QString CPPEditor::autoComplete(QTextCursor &cursor, const QString &text) const
if
(
!
contextAllowsAutoParentheses
(
cursor
))
return
QString
();
QChar
lookAhead
=
characterAt
(
cursor
.
selectionEnd
());
QString
autoText
;
int
skippedChars
=
0
;
MatchingText
matchingText
;
autoText
=
matchingText
.
insertMatchingBrace
(
cursor
,
text
,
&
skippedChars
);
autoText
=
matchingText
.
insertMatchingBrace
(
cursor
,
text
,
lookAhead
,
&
skippedChars
);
if
(
skippedChars
)
{
const
int
pos
=
cursor
.
position
();
...
...
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