From 4dfc5759abe17e2fefd99e16f1dac2edcdb25463 Mon Sep 17 00:00:00 2001 From: Aleksey Dobrunov Date: Sat, 19 Oct 2024 00:01:35 +0500 Subject: [PATCH] fixed a bug/freeze when resizing the window in which a paired object is selected fix #35 --- CHANGELOG.md | 1 + src/colorer/editor/BaseEditor.cpp | 16 +++++++++------- src/colorer/editor/BaseEditor.h | 2 +- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f295d12..107b68d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/src/colorer/editor/BaseEditor.cpp b/src/colorer/editor/BaseEditor.cpp index 469e50d..9b0656b 100644 --- a/src/colorer/editor/BaseEditor.cpp +++ b/src/colorer/editor/BaseEditor.cpp @@ -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; @@ -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; @@ -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 { @@ -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); } diff --git a/src/colorer/editor/BaseEditor.h b/src/colorer/editor/BaseEditor.h index 4b8c66d..d3827b4 100644 --- a/src/colorer/editor/BaseEditor.h +++ b/src/colorer/editor/BaseEditor.h @@ -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