Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dangerous use of undo grouping #455

Closed
b4n opened this issue Jun 25, 2016 · 2 comments
Closed

Dangerous use of undo grouping #455

b4n opened this issue Jun 25, 2016 · 2 comments
Assignees
Milestone

Comments

@b4n
Copy link
Member

b4n commented Jun 25, 2016

GeanyLatex may (at least technically, but I think it's a real bug) start an undo action an never end it. This could break Geany's whole undoing capability when triggered.

The incriminated code is in glatex_structure_lvlup(): an undo action is started unconditionally, but ended conditionally. That is, if utils_string_replace_all() returns 0 replacement for all GLATEX_STRUCTUREs, the undo grouping won't be ended.

@frlan
Copy link
Member

frlan commented Jun 25, 2016

@b4n I guess this will fix it, doesn't it?

diff --git a/geanylatex/src/latexstructure.c b/geanylatex/src/latexstructure.c
index b06a9d2..f16cd38 100644
--- a/geanylatex/src/latexstructure.c
+++ b/geanylatex/src/latexstructure.c
@@ -94,11 +94,10 @@ void glatex_structure_lvlup(void)
                        haystack = NULL;
                        sci_replace_sel(doc->editor->sci, tmp);
                        g_free(tmp);
-                       sci_end_undo_action(doc->editor->sci);
                        break;
                }
        }
-
+       sci_end_undo_action(doc->editor->sci);
        if (haystack != NULL)
                g_string_free(haystack, TRUE);
 }

@b4n
Copy link
Member Author

b4n commented Jun 25, 2016

@frlan yes something like that would fix it

@frlan frlan closed this as completed in b879af2 Jun 25, 2016
@b4n b4n added this to the 1.28.0 milestone Jun 25, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants