- fix: indents calculation for the line succeeding "*/"
This commit is contained in:
parent
c98e169fa3
commit
bca0a3abc1
1
NEWS.md
1
NEWS.md
|
@ -15,6 +15,7 @@ Version 0.8.1 For Dev-C++ 7 Beta
|
||||||
- fix: Installer should install the app in "program files", not "program files (x86)"
|
- fix: Installer should install the app in "program files", not "program files (x86)"
|
||||||
- fix: symbol completion for '/*' not work
|
- fix: symbol completion for '/*' not work
|
||||||
- fix: javadoc-style docstring indents calculation
|
- fix: javadoc-style docstring indents calculation
|
||||||
|
- fix: indents calculation for the line succeeding "*/"
|
||||||
|
|
||||||
Version 0.8 For Dev-C++ 7 Beta
|
Version 0.8 For Dev-C++ 7 Beta
|
||||||
- fix: find in the current file is not correcly saved in the search history
|
- fix: find in the current file is not correcly saved in the search history
|
||||||
|
|
|
@ -1664,9 +1664,7 @@ bool Editor::handleSymbolCompletion(QChar key)
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
case '*':
|
case '*':
|
||||||
qDebug()<<"???";
|
|
||||||
status = getQuoteStatus();
|
status = getQuoteStatus();
|
||||||
qDebug()<<(int)status;
|
|
||||||
if (pSettings->editor().completeComment() && (status == QuoteStatus::NotQuote)) {
|
if (pSettings->editor().completeComment() && (status == QuoteStatus::NotQuote)) {
|
||||||
return handleMultilineCommentCompletion();
|
return handleMultilineCommentCompletion();
|
||||||
}
|
}
|
||||||
|
@ -1771,7 +1769,6 @@ bool Editor::handleBracketSkip()
|
||||||
|
|
||||||
bool Editor::handleMultilineCommentCompletion()
|
bool Editor::handleMultilineCommentCompletion()
|
||||||
{
|
{
|
||||||
qDebug()<<caretX()-1<<" "<<lineText().length();
|
|
||||||
if ((caretX()-2 < lineText().length()) && (lineText()[caretX() - 2] == '/')) {
|
if ((caretX()-2 < lineText().length()) && (lineText()[caretX() - 2] == '/')) {
|
||||||
beginUpdate();
|
beginUpdate();
|
||||||
commandProcessor(SynEditorCommand::ecChar,'*');
|
commandProcessor(SynEditorCommand::ecChar,'*');
|
||||||
|
|
|
@ -1396,6 +1396,26 @@ void SynEdit::setWordBlock(BufferCoord Value)
|
||||||
setCaretAndSelection(v_WordEnd, v_WordStart, v_WordEnd);
|
setCaretAndSelection(v_WordEnd, v_WordStart, v_WordEnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int SynEdit::findCommentStartLine(int searchStartLine)
|
||||||
|
{
|
||||||
|
int commentStartLine = searchStartLine;
|
||||||
|
SynRangeState range;
|
||||||
|
while (commentStartLine>=1) {
|
||||||
|
range = mLines->ranges(commentStartLine-1);
|
||||||
|
if (!mHighlighter->isLastLineCommentNotFinished(range.state)){
|
||||||
|
commentStartLine++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (!range.matchingIndents.isEmpty()
|
||||||
|
|| range.firstIndentThisLine<range.indents.length())
|
||||||
|
break;
|
||||||
|
commentStartLine--;
|
||||||
|
}
|
||||||
|
if (commentStartLine<1)
|
||||||
|
commentStartLine = 1;
|
||||||
|
return commentStartLine;
|
||||||
|
}
|
||||||
|
|
||||||
int SynEdit::calcIndentSpaces(int line, const QString& lineText, bool addIndent)
|
int SynEdit::calcIndentSpaces(int line, const QString& lineText, bool addIndent)
|
||||||
{
|
{
|
||||||
if (!mHighlighter)
|
if (!mHighlighter)
|
||||||
|
@ -1422,6 +1442,12 @@ int SynEdit::calcIndentSpaces(int line, const QString& lineText, bool 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;
|
||||||
|
if (startLine>1) {
|
||||||
|
statePrePre = mLines->ranges(startLine-2).state;
|
||||||
|
} else {
|
||||||
|
statePrePre = 0;
|
||||||
|
}
|
||||||
SynRangeState rangeAfterFirstToken = mHighlighter->getRangeState();
|
SynRangeState rangeAfterFirstToken = mHighlighter->getRangeState();
|
||||||
QString firstToken = mHighlighter->getToken();
|
QString firstToken = mHighlighter->getToken();
|
||||||
PSynHighlighterAttribute attr = mHighlighter->getTokenAttribute();
|
PSynHighlighterAttribute attr = mHighlighter->getTokenAttribute();
|
||||||
|
@ -1454,29 +1480,26 @@ int SynEdit::calcIndentSpaces(int line, const QString& lineText, bool addIndent)
|
||||||
// it means this line is a docstring, should indents according to
|
// it means this line is a docstring, should indents according to
|
||||||
// the line the comment beginning , and add 1 additional space
|
// the line the comment beginning , and add 1 additional space
|
||||||
additionIndent = 1;
|
additionIndent = 1;
|
||||||
int commentStartLine = startLine-1;
|
int commentStartLine = findCommentStartLine(startLine-1);
|
||||||
|
SynRangeState range;
|
||||||
|
indentSpaces = leftSpaces(mLines->getString(commentStartLine-1));
|
||||||
|
range = mLines->ranges(commentStartLine-1);
|
||||||
|
matchingIndents = range.matchingIndents;
|
||||||
|
dontAddIndent = true;
|
||||||
|
l = commentStartLine;
|
||||||
|
} else if ( mHighlighter->isLastLineCommentNotFinished(statePrePre)
|
||||||
|
&& rangePreceeding.matchingIndents.isEmpty()
|
||||||
|
&& rangePreceeding.firstIndentThisLine>=rangePreceeding.indents.length()
|
||||||
|
&& !mHighlighter->isLastLineCommentNotFinished(rangePreceeding.state)) {
|
||||||
|
// the preceeding line is the end of comment
|
||||||
|
// we should use the indents of the start line of the comment
|
||||||
|
int commentStartLine = findCommentStartLine(startLine-2);
|
||||||
SynRangeState range;
|
SynRangeState range;
|
||||||
while (commentStartLine>=1) {
|
|
||||||
range = mLines->ranges(commentStartLine-1);
|
|
||||||
if (!mHighlighter->isLastLineCommentNotFinished(range.state)){
|
|
||||||
commentStartLine++;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (!range.matchingIndents.isEmpty()
|
|
||||||
|| range.firstIndentThisLine<range.indents.length())
|
|
||||||
break;
|
|
||||||
commentStartLine--;
|
|
||||||
}
|
|
||||||
if (commentStartLine<1)
|
|
||||||
commentStartLine = 1;
|
|
||||||
indentSpaces = leftSpaces(mLines->getString(commentStartLine-1));
|
indentSpaces = leftSpaces(mLines->getString(commentStartLine-1));
|
||||||
range = mLines->ranges(commentStartLine-1);
|
range = mLines->ranges(commentStartLine-1);
|
||||||
matchingIndents = range.matchingIndents;
|
matchingIndents = range.matchingIndents;
|
||||||
dontAddIndent = true;
|
dontAddIndent = true;
|
||||||
l = commentStartLine;
|
l = commentStartLine;
|
||||||
} else if (trimmedS.startsWith("*")) {
|
|
||||||
// fix indents for line like " */"
|
|
||||||
indentSpaces--;
|
|
||||||
} else {
|
} else {
|
||||||
// we just use infos till preceeding line's end to calc indents
|
// we just use infos till preceeding line's end to calc indents
|
||||||
matchingIndents = rangePreceeding.matchingIndents;
|
matchingIndents = rangePreceeding.matchingIndents;
|
||||||
|
|
|
@ -514,9 +514,9 @@ private:
|
||||||
void setSelWord();
|
void setSelWord();
|
||||||
void setWordBlock(BufferCoord Value);
|
void setWordBlock(BufferCoord Value);
|
||||||
|
|
||||||
|
int findCommentStartLine(int searchStartLine);
|
||||||
int calcIndentSpaces(int line, const QString& lineText, bool addIndent);
|
int calcIndentSpaces(int line, const QString& lineText, bool addIndent);
|
||||||
|
|
||||||
|
|
||||||
void processGutterClick(QMouseEvent* event);
|
void processGutterClick(QMouseEvent* event);
|
||||||
|
|
||||||
void clearUndo();
|
void clearUndo();
|
||||||
|
|
Loading…
Reference in New Issue