Prevent Prompt on Reload #351
Unanswered
eric-hemasystems
asked this question in
Q&A
Replies: 1 comment
-
No, that is the way to do it. For `events.FILE_CHANGED`, there are no
other handlers, so there is no risk of overriding the default behavior.
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I would like to prevent Textadept from prompting me when the file changes on the filesystem. I would rather it just reload the file automatically.
I may have 4-6 buffers open at any given time and if I switch branches I get prompt after prompt asking me if I want to reload various files. I would rather is just assume if the file on disk changes I want the latest changes to that file visible in Textadept without prompting me.
In the documentation for the
FILE_CHANGED
event the API documentation says:This sounds a bit like what I'm looking for although it's talking more about overriding the message not really stopping the prompt. Just in case I gave it a whirl and tried unconditionally reloading after installing the hook:
No luck. :(. Next I did a bit of searching in the source code to see if I could figure out how to do it. I think I found the relevant code at:
textadept/core/file_io.lua
Lines 299 to 308 in 96f58f1
The code seems to be unconditionally prompting. I can install an event handler that cancels further handlers. Something like:
This works but it feels heavy handed as it cancels all other event handlers attached to that event. I searched the code base for any other handlers and I think it is the only one but perhaps other modules might use that event or something.
Ideally I could use
events.disconnect
but since it's an anonymous function I don't have any way to get a reference to that function.Is there any other (probably obvious) way to do this?
Beta Was this translation helpful? Give feedback.
All reactions