Skip to content

Commit

Permalink
fixed a bug/freeze when resizing the window in which a paired object …
Browse files Browse the repository at this point in the history
…is selected

fix #35
  • Loading branch information
ctapmex committed Oct 18, 2024
1 parent bc42496 commit 4dfc575
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
### Fixed
- Build on old Linux platform. A minimum of gcc 7 is required.
- Build on Linux ARM64, *BSD, macOS
- Fixed a bug/freeze when resizing the window in which a paired object is selected

### Changed
- The library for logging spdlog has been replaced by own implementation.
Expand Down
16 changes: 9 additions & 7 deletions src/colorer/editor/BaseEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,9 @@ void BaseEditor::removeEditorListener(EditorListener* el)
}
}

PairMatch* BaseEditor::getPairMatch(int lineNo, int linePos)
PairMatch* BaseEditor::getPairMatch(int lineNo, int linePos, LineRegion** lineRegion)
{
*lineRegion = nullptr;
LineRegion* lrStart = getLineRegions(lineNo);
if (lrStart == nullptr) {
return nullptr;
Expand All @@ -235,6 +236,7 @@ PairMatch* BaseEditor::getPairMatch(int lineNo, int linePos)
if (pair != nullptr) {
auto* pm = new PairMatch(pair, lineNo, pair->region->hasParent(def_PairStart));
pm->setStart(pair);
*lineRegion = lrStart;
return pm;
}
return nullptr;
Expand All @@ -250,17 +252,16 @@ void BaseEditor::releasePairMatch(PairMatch* pm)
delete pm;
}

PairMatch* BaseEditor::searchPair(int lineNo, int pos, int start_line, int end_line){
int lno;
PairMatch* pm = getPairMatch(lineNo, pos);
PairMatch* BaseEditor::searchPair(int lineNo, int pos, int start_line, int end_line)
{
LineRegion* slr = nullptr;
PairMatch* pm = getPairMatch(lineNo, pos, &slr);
if (pm == nullptr) {
return nullptr;
}

lno = pm->sline;

int lno = pm->sline;
LineRegion* pair = pm->getStartRef();
LineRegion* slr = getLineRegions(lno);
while (true) {
if (pm->pairBalance > 0) {
do {
Expand All @@ -271,6 +272,7 @@ PairMatch* BaseEditor::searchPair(int lineNo, int pos, int start_line, int end_l
return pm;
}
pair = getLineRegions(lno);
slr = pair;
}
} while (!pair->region);
}
Expand Down
2 changes: 1 addition & 1 deletion src/colorer/editor/BaseEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ class BaseEditor : public RegionHandler
* Searches for the paired token and creates PairMatch
* object with valid initial properties filled.
*/
PairMatch* getPairMatch(int lineNo, int pos);
PairMatch* getPairMatch(int lineNo, int pos, LineRegion** line_region);
};

#endif

0 comments on commit 4dfc575

Please sign in to comment.