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 itssynchronous
param 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.Jobs
channel.The 1st case probably only causes unneeded redraws. Even if the
drawChan
gets 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.Jobs
channel 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.