#611 Checking for changed external files on key presses is wrong

open
nobody
None
5
2012-07-25
2012-07-25
No

The main keypress handler on_key_press_event() checks for external
file changes of the current open tab. If it finds one it asks the user if
he wants to reload the document.

After returning from that check and after possibly reloading
the file the key is processed normally, If the key is interacting
with the editor e.g. a "normal" character key that inserts a
character in the document, the key press changes the document
that was just reloaded which is most probably unwanted.

But when pondering the whole issue and possible solutions
i came to the conclusion that checking for changed files
in the key handler is wrong altogether. The current method
does not only change newly reloaded documents it does also
reload files when the key press has nothing to do with the editor
itself at all. Because key presses happen so often the code even
tries to mitigate the performance problem by checking only
after a configurable timeout.

Using keypresses as a poor man's scheduler is just wrong.

We should add a scheme that monitors open files with
libnotify for example to get notifications instantly.
I am not familiar enough with geany to add it myself
though. Multiplatform considerations apply too.

Discussion

  • Anonymous - 2012-07-25

    I never noticed Geany checking for on disk file changes on keypress, only on tab change/timer, but it's possible. There is code in place already to use GFileMonitor (wrapper around the various inotify type things), but it's not turned on at compile time for whatever reason. You can turn it on by recompiling after uncommenting `#define USE_GIO_FILEMON` on line 48 of document.c. IMO, we should use this since in my minimal testing it seems to work fine.

     
  • Lex Trotman

    Lex Trotman - 2012-09-15

    @codebrainz, GIO file monitoring doesn't work due to multiple notifications in some circumstances, which can result in multiple annoying notifications, thats why its turned off. It was found to be more trouble than benefit.

    The keypress paradigm is also a proxy for "the user is interacting with Geany" so it is unlikely that the modal dialog will disrupt using another application which would happen if pure timing is used.

    Until we are on a new enough GTK that we can use codebrainz prototype non-invasive notification system it is unlikely that the approach will change.

     

Log in to post a comment.