- fix: calculation of the code block ranges when inserting/deleting
This commit is contained in:
parent
1a36822b18
commit
76f0b9d17b
1
NEWS.md
1
NEWS.md
|
@ -7,6 +7,7 @@ Red Panda C++ Version 1.1.4
|
||||||
- enhancement: only allow insert linebreak at the end of folded code block
|
- enhancement: only allow insert linebreak at the end of folded code block
|
||||||
- enhancement: only allow delete whole folded code block
|
- enhancement: only allow delete whole folded code block
|
||||||
- refactor of undo system
|
- refactor of undo system
|
||||||
|
- fix: calculation of the code block ranges when inserting/deleting
|
||||||
|
|
||||||
Red Panda C++ Version 1.1.3
|
Red Panda C++ Version 1.1.3
|
||||||
|
|
||||||
|
|
|
@ -3570,13 +3570,11 @@ void SynEdit::foldOnListInserted(int Line, int Count)
|
||||||
// Delete collapsed inside selection
|
// Delete collapsed inside selection
|
||||||
for (int i = mAllFoldRanges.count()-1;i>=0;i--) {
|
for (int i = mAllFoldRanges.count()-1;i>=0;i--) {
|
||||||
PSynEditFoldRange range = mAllFoldRanges[i];
|
PSynEditFoldRange range = mAllFoldRanges[i];
|
||||||
if (range->collapsed || range->parentCollapsed()){
|
if (range->fromLine == Line - 1) {// insertion starts at fold line
|
||||||
qDebug()<<range->fromLine<<Line;
|
if (range->collapsed)
|
||||||
if (range->fromLine == Line - 1) // insertion starts at fold line
|
|
||||||
uncollapse(range);
|
uncollapse(range);
|
||||||
else if (range->fromLine >= Line) // insertion of count lines above FromLine
|
} else if (range->fromLine >= Line) // insertion of count lines above FromLine
|
||||||
range->move(Count);
|
range->move(Count);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3585,15 +3583,14 @@ void SynEdit::foldOnListDeleted(int Line, int Count)
|
||||||
// Delete collapsed inside selection
|
// Delete collapsed inside selection
|
||||||
for (int i = mAllFoldRanges.count()-1;i>=0;i--) {
|
for (int i = mAllFoldRanges.count()-1;i>=0;i--) {
|
||||||
PSynEditFoldRange range = mAllFoldRanges[i];
|
PSynEditFoldRange range = mAllFoldRanges[i];
|
||||||
if (range->collapsed || range->parentCollapsed()){
|
if (range->fromLine == Line && Count == 1) {// open up because we are messing with the starting line
|
||||||
qDebug()<<range->fromLine<<Line;
|
if (range->collapsed)
|
||||||
if (range->fromLine == Line && Count == 1) // open up because we are messing with the starting line
|
|
||||||
uncollapse(range);
|
uncollapse(range);
|
||||||
else if (range->fromLine >= Line - 1 && range->fromLine < Line + Count) // delete inside affectec area
|
} else if (range->fromLine >= Line - 1 && range->fromLine < Line + Count) // delete inside affectec area
|
||||||
mAllFoldRanges.remove(i);
|
mAllFoldRanges.remove(i);
|
||||||
else if (range->fromLine >= Line + Count) // Move after affected area
|
else if (range->fromLine >= Line + Count) // Move after affected area
|
||||||
range->move(-Count);
|
range->move(-Count);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3616,11 +3613,11 @@ static void null_deleter(SynEditFoldRanges *) {}
|
||||||
void SynEdit::rescanForFoldRanges()
|
void SynEdit::rescanForFoldRanges()
|
||||||
{
|
{
|
||||||
// Delete all uncollapsed folds
|
// Delete all uncollapsed folds
|
||||||
for (int i=mAllFoldRanges.count()-1;i>=0;i--) {
|
// for (int i=mAllFoldRanges.count()-1;i>=0;i--) {
|
||||||
PSynEditFoldRange range =mAllFoldRanges[i];
|
// PSynEditFoldRange range =mAllFoldRanges[i];
|
||||||
if (!range->collapsed && !range->parentCollapsed())
|
// if (!range->collapsed && !range->parentCollapsed())
|
||||||
mAllFoldRanges.remove(i);
|
// mAllFoldRanges.remove(i);
|
||||||
}
|
// }
|
||||||
|
|
||||||
// Did we leave any collapsed folds and are we viewing a code file?
|
// Did we leave any collapsed folds and are we viewing a code file?
|
||||||
if (mAllFoldRanges.count() > 0) {
|
if (mAllFoldRanges.count() > 0) {
|
||||||
|
@ -3630,21 +3627,26 @@ void SynEdit::rescanForFoldRanges()
|
||||||
PSynEditFoldRanges TemporaryAllFoldRanges = std::make_shared<SynEditFoldRanges>();
|
PSynEditFoldRanges TemporaryAllFoldRanges = std::make_shared<SynEditFoldRanges>();
|
||||||
scanForFoldRanges(TemporaryAllFoldRanges);
|
scanForFoldRanges(TemporaryAllFoldRanges);
|
||||||
|
|
||||||
|
qDebug()<<" ------- ";
|
||||||
// Combine new with old folds, preserve parent order
|
// Combine new with old folds, preserve parent order
|
||||||
for (int i = 0; i< TemporaryAllFoldRanges->count();i++) {
|
for (int i = 0; i< TemporaryAllFoldRanges->count();i++) {
|
||||||
|
PSynEditFoldRange tempFoldRange=TemporaryAllFoldRanges->range(i);
|
||||||
int j=0;
|
int j=0;
|
||||||
while (j <ranges.count()) {
|
while (j <ranges.count()) {
|
||||||
// qDebug()<<TemporaryAllFoldRanges->range(i)->fromLine<<ranges[j]->fromLine;
|
PSynEditFoldRange foldRange = ranges[j];
|
||||||
if (TemporaryAllFoldRanges->range(i)->fromLine == ranges[j]->fromLine
|
//qDebug()<<TemporaryAllFoldRanges->range(i)->fromLine<<ranges[j]->fromLine;
|
||||||
&& TemporaryAllFoldRanges->range(i)->toLine == ranges[j]->toLine) {
|
if (tempFoldRange->fromLine == foldRange->fromLine
|
||||||
mAllFoldRanges.add(ranges[j]);
|
&& tempFoldRange->toLine == foldRange->toLine) {
|
||||||
|
//qDebug()<<"-"<<foldRange->fromLine;
|
||||||
|
mAllFoldRanges.add(foldRange);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
if (j>=ranges.count())
|
if (j>=ranges.count()) {
|
||||||
mAllFoldRanges.add(TemporaryAllFoldRanges->range(i));
|
//qDebug()<<"--"<<tempFoldRange->fromLine;
|
||||||
|
mAllFoldRanges.add(tempFoldRange);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue