[Github-comments] [geany] Don't explicitly re-highlight the document when typenames change (#575)

Jiří Techet notifications at xxxxx
Sat Dec 12 14:17:38 UTC 2015


>
> I just tried the patch and it doesn't seem to work for me, if I change a
> type name other occurrences of it don't change:
>
> typedef int bar;
>
> bar z;
>
> if you change the name of the typedef, the typedef itself gets
> re-highlighted when the cursor blinks (roughly a second later), but the
> usage below don't.
>
OK, right - the color would get updated only after you start typing.

> However, instead of re-colorizing everything maybe we could only colorize
> up to the end of the visible area, which would mitigate (or even
> eradicate?) the slowness:
>
> diff --git a/src/editor.c b/src/editor.c
> index 1336588..cfbfbe9 100644--- a/src/editor.c+++ b/src/editor.c@@ -4682,12 +4682,20 @@ on_editor_scroll_event(GtkWidget *widget, GdkEventScroll *event, gpointer user_d
>  static gboolean editor_check_colourise(GeanyEditor *editor)
>  {
>      GeanyDocument *doc = editor->document;+    gint start_line, end_line, start, end;
>
>      if (!doc->priv->colourise_needed)
>          return FALSE;
> +    start_line = SSM(editor->sci, SCI_GETFIRSTVISIBLELINE, 0, 0);+    end_line = start_line + SSM(editor->sci, SCI_LINESONSCREEN, 0, 0);+    start_line = SSM(editor->sci, SCI_DOCLINEFROMVISIBLE, start_line, 0);+    end_line = SSM(editor->sci, SCI_DOCLINEFROMVISIBLE, end_line, 0);+    start = sci_get_position_from_line(editor->sci, start_line);+    end = sci_get_line_end_position(editor->sci, end_line);+
>      doc->priv->colourise_needed = FALSE;-    sci_colourise(editor->sci, 0, -1);+    sci_colourise(editor->sci, start, end);
>
>      /* now that the current document is colourised, fold points are now accurate,
>       * so force an update of the current function/tag. */
>
>
> This is insufficient because when the document gets loaded, we need to
perform the whole-document colorization otherwise we won't get valid fold
points ("fold all" doesn't work as expected with your patch).

Anyway, we can have two types of colorization - full, performed on document
load, and partial (the one from your patch), performed only to recolorize
typenames (they won't modify fold points in any way so it should be safe).
I've updated the patch with this and it seems to work well.

(The updated patch still fixes the performance problem - the visible area
colorization appears to be cheap.)


---
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/pull/575#issuecomment-164157945
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.geany.org/pipermail/github-comments/attachments/20151212/38ac8ddd/attachment.html>


More information about the Github-comments mailing list