0
0
mirror of https://github.com/fralx/LimeReport.git synced 2024-12-24 00:33:02 +03:00

Script editor fixed

This commit is contained in:
Arin Alexander 2017-10-04 17:14:07 +03:00
parent 6cd3f96907
commit 0f915a9581

View File

@ -148,31 +148,33 @@ QString CodeEditor::textUnderCursor() const
bool CodeEditor::matchLeftParenthesis(QTextBlock currentBlock, QChar parenthesisType, int i, int numLeftParentheses)
{
TextBlockData *data = static_cast<TextBlockData *>(currentBlock.userData());
QVector<ParenthesisInfo *> infos = data->parentheses();
if (data){
QVector<ParenthesisInfo *> infos = data->parentheses();
int docPos = currentBlock.position();
for (; i < infos.size(); ++i) {
ParenthesisInfo *info = infos.at(i);
int docPos = currentBlock.position();
for (; i < infos.size(); ++i) {
ParenthesisInfo *info = infos.at(i);
if (info->character == parenthesisType) {
++numLeftParentheses;
continue;
}
if (info->character == getParenthesisReverceChar(parenthesisType)){
if (numLeftParentheses == 0) {
createParenthesisSelection(docPos + info->position);
return true;
} else
--numLeftParentheses;
}
if (info->character == parenthesisType) {
++numLeftParentheses;
continue;
}
if (info->character == getParenthesisReverceChar(parenthesisType)){
if (numLeftParentheses == 0) {
createParenthesisSelection(docPos + info->position);
return true;
} else
--numLeftParentheses;
}
currentBlock = currentBlock.next();
if (currentBlock.isValid())
return matchLeftParenthesis(currentBlock, parenthesisType, 0, numLeftParentheses);
}
currentBlock = currentBlock.next();
if (currentBlock.isValid())
return matchLeftParenthesis(currentBlock, parenthesisType, 0, numLeftParentheses);
return false;
}
@ -180,27 +182,28 @@ bool CodeEditor::matchRightParenthesis(QTextBlock currentBlock, QChar parenthesi
{
TextBlockData *data = static_cast<TextBlockData *>(currentBlock.userData());
QVector<ParenthesisInfo *> parentheses = data->parentheses();
if (data){
int docPos = currentBlock.position();
for (; i > -1 && parentheses.size() > 0; --i) {
ParenthesisInfo *info = parentheses.at(i);
if (info->character == parenthesisType) {
++numRightParentheses;
continue;
}
if (info->character == getParenthesisReverceChar(parenthesisType)){
if (numRightParentheses == 0) {
createParenthesisSelection(docPos + info->position);
return true;
} else
--numRightParentheses;
}
}
currentBlock = currentBlock.previous();
if (currentBlock.isValid())
return matchRightParenthesis(currentBlock, parenthesisType, 0, numRightParentheses);
int docPos = currentBlock.position();
for (; i > -1 && parentheses.size() > 0; --i) {
ParenthesisInfo *info = parentheses.at(i);
if (info->character == parenthesisType) {
++numRightParentheses;
continue;
}
if (info->character == getParenthesisReverceChar(parenthesisType)){
if (numRightParentheses == 0) {
createParenthesisSelection(docPos + info->position);
return true;
} else
--numRightParentheses;
}
}
currentBlock = currentBlock.previous();
if (currentBlock.isValid())
return matchRightParenthesis(currentBlock, parenthesisType, 0, numRightParentheses);
return false;
}