-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Add onAnyEvent callback
#3244
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
Merged
Merged
Add onAnyEvent callback
#3244
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it's worth mentioning, that the indication takes place before the update of the display is done.
Hopefully this doesn't lead to redraw-loops in the moment someone reacts to such an event, triggering an action, which then creates the next event and so on. 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is the same situation as with other callbacks, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In case of drawing...yes, I think so. Then it's common sense...
In case of possible cb-event-ping-pong the possible frequency could be higher, but it's up to the plugin (developer) to not shoot his self.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally, this should never happen, assuming that any events received by
DoEvent()can be only triggered by other goroutines (and thus cannot be triggered by lua callbacks, since they run in the main goroutine).I've briefly looked through the code to check if this is actually true... Looks like there actually is a couple of cases when the main goroutine may send an event to itself:
UpdateDiff()calls its callback which sends a redraw event regardless of itssynchronousparam value, e.g. even if this callback is running in the main goroutine.Terminal.Close()(which is called from the main goroutine e.g. when the user closes a termpane via Ctrl-q + Ctrl-q) may send a job event to theshell.Jobschannel.The 1st case probably only causes unneeded redraws. Even if the
drawChangets overfull with those extra redraw events, it will not cause a deadlock, sincescreen.Redraw()doesn't block but simply drops events in such case.But the 2nd case, it seems, may cause a deadlock (very unlikely to happen in practice though), if the main goroutine is closing many termpanes (100+ termpanes) fast enough, causing the
shell.Jobschannel overfull and thus blocking forever.Both these cases seem to be worth fixing (especially the 2nd one), even though they are rather minor, - just to feel safe and clean, by guaranteeing no ping-pong ever, no deadlocks ever, no redundant events.