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
9822fb65
Commit
9822fb65
authored
Oct 31, 2009
by
Roopesh Chander
Committed by
Thorbjørn Lindeijer
Feb 08, 2010
Browse files
cleanWhitespace() checkes whether it has to change indentation or not. handle that.
parent
fde76601
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/plugins/texteditor/basetextdocument.cpp
View file @
9822fb65
...
...
@@ -327,7 +327,7 @@ void BaseTextDocument::cleanWhitespace(QTextCursor& cursor, bool cleanIndentatio
cursor
.
movePosition
(
QTextCursor
::
PreviousCharacter
,
QTextCursor
::
KeepAnchor
,
trailing
);
cursor
.
removeSelectedText
();
}
if
(
cleanIndentation
&&
!
m_tabSettings
.
isIndentationClean
(
block
Text
))
{
if
(
cleanIndentation
&&
!
m_tabSettings
.
isIndentationClean
(
block
))
{
cursor
.
setPosition
(
block
.
position
());
int
firstNonSpace
=
m_tabSettings
.
firstNonSpace
(
blockText
);
if
(
firstNonSpace
==
blockText
.
length
())
{
...
...
src/plugins/texteditor/tabsettings.cpp
View file @
9822fb65
...
...
@@ -149,10 +149,12 @@ int TabSettings::trailingWhitespaces(const QString &text) const
return
i
;
}
bool
TabSettings
::
isIndentationClean
(
const
Q
String
&
text
)
const
bool
TabSettings
::
isIndentationClean
(
const
Q
TextBlock
&
block
)
const
{
int
i
=
0
;
int
spaceCount
=
0
;
QString
text
=
block
.
text
();
bool
spacesForTabs
=
guessSpacesForTabs
(
block
);
while
(
i
<
text
.
size
())
{
QChar
c
=
text
.
at
(
i
);
if
(
!
c
.
isSpace
())
...
...
@@ -160,10 +162,10 @@ bool TabSettings::isIndentationClean(const QString &text) const
if
(
c
==
QLatin1Char
(
' '
))
{
++
spaceCount
;
if
(
!
m_
spacesForTabs
&&
spaceCount
==
m_tabSize
)
if
(
!
spacesForTabs
&&
spaceCount
==
m_tabSize
)
return
false
;
}
else
if
(
c
==
QLatin1Char
(
'\t'
))
{
if
(
m_
spacesForTabs
||
spaceCount
!=
m_indentSize
)
if
(
spacesForTabs
||
spaceCount
!=
m_indentSize
)
return
false
;
spaceCount
=
0
;
}
...
...
src/plugins/texteditor/tabsettings.h
View file @
9822fb65
...
...
@@ -72,7 +72,7 @@ struct TEXTEDITOR_EXPORT TabSettings
void
reindentLine
(
QTextBlock
block
,
int
delta
)
const
;
int
trailingWhitespaces
(
const
QString
&
text
)
const
;
bool
isIndentationClean
(
const
Q
String
&
text
)
const
;
bool
isIndentationClean
(
const
Q
TextBlock
&
block
)
const
;
bool
tabShouldIndent
(
const
QTextDocument
*
document
,
QTextCursor
cursor
,
int
*
suggestedPosition
=
0
)
const
;
bool
guessSpacesForTabs
(
const
QTextBlock
&
block
)
const
;
...
...
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