On Sat, 24 Nov 2012 14:09:12 +0000 Nick Treleaven nick.treleaven@btinternet.com wrote:
I played with this a little. It won't work easily because document_set_text_changed is sometimes called to force a UI update, possibly even when the current doc hasn't changed. [...]
On Sat, 24 Nov 2012 15:11:48 -0600 Evandro Borracini evandro.borracini@gmail.com wrote:
Thanks everyone for the comments and suggestions. Based on them, I reverted back to the original code and just added an "if (doc->changed != TRUE)" before calling document_set_text_changed (doc, TRUE) in document_undo/redo_add().
document_redo_add(doc, UNDO_SCINTILLA, NULL); <-- text changed document_redo_add(doc, UNDO_BOM, GINT_TO_POINTER(doc->has_bom)); document_redo_add(doc, UNDO_ENCODING, g_strdup(doc->encoding));
The 2nd and 3rd call probably rely on redo_add to call document_set_text_changed(), to update the status bar. You can check that (my Geany version is a bit outdated), and update the patch to call set_text for BOM/ENCODING (they are rare). Same for undo.
Aside from that, the patch looks reasonable. For plugins, we allow document_set_text_changed(), but not undo/redo_add(), which is OK.