work save
This commit is contained in:
parent
da1dc2e856
commit
bb5d1b706c
|
@ -1453,21 +1453,21 @@ int SynEdit::calcIndentSpaces(int line, const QString& lineText, bool addIndent)
|
||||||
return 0;
|
return 0;
|
||||||
// find the first non-empty preceeding line
|
// find the first non-empty preceeding line
|
||||||
int startLine = line-1;
|
int startLine = line-1;
|
||||||
QString s;
|
QString startLineText;
|
||||||
while (startLine>=1) {
|
while (startLine>=1) {
|
||||||
s = mLines->getString(startLine-1);
|
startLineText = mLines->getString(startLine-1);
|
||||||
if (!s.startsWith('#') && !s.trimmed().isEmpty()) {
|
if (!startLineText.startsWith('#') && !startLineText.trimmed().isEmpty()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
startLine -- ;
|
startLine -- ;
|
||||||
}
|
}
|
||||||
int indentSpaces = 0;
|
int indentSpaces = 0;
|
||||||
if (startLine>=1) {
|
if (startLine>=1) {
|
||||||
indentSpaces = leftSpaces(s);
|
indentSpaces = leftSpaces(startLineText);
|
||||||
SynRangeState rangePreceeding = mLines->ranges(startLine-1);
|
SynRangeState rangePreceeding = mLines->ranges(startLine-1);
|
||||||
mHighlighter->setState(rangePreceeding);
|
mHighlighter->setState(rangePreceeding);
|
||||||
if (addIndent) {
|
if (addIndent) {
|
||||||
QString trimmedS = s.trimmed();
|
// QString trimmedS = s.trimmed();
|
||||||
QString trimmedLineText = lineText.trimmed();
|
QString trimmedLineText = lineText.trimmed();
|
||||||
mHighlighter->setLine(trimmedLineText,line-1);
|
mHighlighter->setLine(trimmedLineText,line-1);
|
||||||
int statePrePre;
|
int statePrePre;
|
||||||
|
@ -1587,7 +1587,7 @@ int SynEdit::calcIndentSpaces(int line, const QString& lineText, bool addIndent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!dontAddIndent && !s.isEmpty()) {
|
if (!dontAddIndent && !startLineText.isEmpty()) {
|
||||||
BufferCoord coord;
|
BufferCoord coord;
|
||||||
QString token;
|
QString token;
|
||||||
PSynHighlighterAttribute attr;
|
PSynHighlighterAttribute attr;
|
||||||
|
@ -2765,7 +2765,6 @@ void SynEdit::doAddChar(QChar AChar)
|
||||||
} else if (AChar == '{' || AChar == '}' || AChar == '#') {
|
} else if (AChar == '{' || AChar == '}' || AChar == '#') {
|
||||||
//Reindent line when add '{' '}' and '#' at the beginning
|
//Reindent line when add '{' '}' and '#' at the beginning
|
||||||
QString left = mLines->getString(oldCaretY-1).mid(0,oldCaretX-1);
|
QString left = mLines->getString(oldCaretY-1).mid(0,oldCaretX-1);
|
||||||
qDebug()<<left<<oldCaretX;
|
|
||||||
// and the first nonblank char is this new {
|
// and the first nonblank char is this new {
|
||||||
if (left.trimmed().isEmpty()) {
|
if (left.trimmed().isEmpty()) {
|
||||||
int indentSpaces = calcIndentSpaces(oldCaretY,AChar, true);
|
int indentSpaces = calcIndentSpaces(oldCaretY,AChar, true);
|
||||||
|
|
Loading…
Reference in New Issue