-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
tui: emit some termcodes later (after startup) #7664
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
Conversation
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
For some reason, enabling focus reporting during terminal setup, causes slow rendering during Nvim startup on tmux 2.3 with the tmux `focus-events` option enabled. To workaround that issue, this commit defers the request. closes neovim#7649 init.vim: call plug#begin('~/.config/nvim/plugged') Plug 'morhetz/gruvbox' call plug#end() set background=light " background light just to see the effect more quickly colorscheme gruvbox .tmux.conf: set -g focus-events on set-option -ga terminal-overrides ",xterm-256color:Tc" set-option -g default-terminal "screen-256color" Using `script` to record the terminal session (and `vterm-dump` to post-process the result): BEFORE this commit: ./build/bin/nvim -u NONE{CR}{LF} {DECSM 1049}{DECSM 1}{ESC =} {CUP *}{ED 2}{DECSM 2004}{DECSM 1004}{CSI 8,44,156 t}{CSI * r} {CUP 1,1} {CUP *}{ED 2}{DECSM 25} {DECRM 25}{CSI 2 q}{CSI 2 q} {CUP *}{ED 2}{LF} {ESC (B}{SGR *}{SGR 94}~ {CR}{LF} ~ {CR}{LF} AFTER this commit: ./build/bin/nvim -u NONE{CR}{LF} {DECSM 1049}{DECSM 1}{ESC =} {CUP *}{ED 2}{CSI 8,44,156 t}{CSI * r} {CUP 1,1} {CUP *}{ED 2}{DECSM 2004}{DECSM 1004}{DECSM 25} {DECRM 25}{CSI 2 q}{CSI 2 q} {CUP *}{ED 2}{LF} {ESC (B}{SGR *}{SGR 94}~ {CR}{LF} ~ {CR}{LF} ...
justinmk
added a commit
to justinmk/neovim
that referenced
this pull request
Dec 2, 2017
ref neovim#7649 ref neovim#7664 27f9b1c caused a regression: it uses loop_schedule_deferred() to defer emitting the "enable focus reporting" termcode. tui_main() never processes `tui_loop.events` (which loop_schedule_deferred() depends on), so the event was never actually processed. But fixing that (by processing `tui_loop.events`) would bring back the problem 27f9b1c tried to fix: it still emits the event too soon. Instead, do a little dance: schedule the event on `main_loop` and then forward it to `tui_loop`. NOTE: after this commit, in tmux 2.3 with `focus-events` enabled, FocusGained is fired on startup and when resuming from suspend. Using `script` to record the terminal session (and `vterm-dump` to post-process the result): BEFORE: {DECSM 1049}{DECSM 1}{ESC =} {CUP *}{ED *}{DECSM 2004}{DECSM 1004}{CSI 1,43 r} {CUP 1,1} {CUP *}{ED *}{SM 34}{DECSM 25} {DECRM 25}{CSI 2 q}{CSI 2 q} {CUP *}{ED *}{LF} {SGR *}{LS1}{SGR 94}~ ... AFTER: {CUP *}{ED *}{CSI 1,43 r} {CUP 1,1} {CUP *}{ED *}{SM 34}{DECSM 25} {DECRM 25}{CSI 2 q}{CSI 2 q} {CUP *}{ED *}{DECSM 2004}{DECSM 1004}{LF} {SGR *}{LS1}{SGR 94}~ ...
justinmk
added a commit
to justinmk/neovim
that referenced
this pull request
Dec 11, 2017
Try another approach to defer the termcodes. Seems less janky, but still not perfect. ref neovim#7664 ref neovim#7649 ref neovim#7664 ref 27f9b1c
justinmk
added a commit
to justinmk/neovim
that referenced
this pull request
Dec 12, 2017
With this implementation there is no "jank" during startup. Using the main_loop in any fashion is janky. Using only the TUI loop emits the termcodes too soon, or requires bad hacks like counting tui_flush invocations (9 seems to work). ref neovim#7664 ref neovim#7649 ref neovim#7664 ref 27f9b1c
justinmk
added a commit
to justinmk/neovim
that referenced
this pull request
Dec 13, 2017
Try another approach to defer the termcodes. Seems less janky, but still not perfect. ref neovim#7664 ref neovim#7649 ref neovim#7664 ref 27f9b1c
justinmk
added a commit
to justinmk/neovim
that referenced
this pull request
Dec 13, 2017
With this implementation there is no "jank" during startup. Using the main_loop in any fashion is janky. Using only the TUI loop emits the termcodes too soon, or requires bad hacks like counting tui_flush invocations (9 seems to work). ref neovim#7664 ref neovim#7649 ref neovim#7664 ref 27f9b1c
justinmk
added a commit
to justinmk/neovim
that referenced
this pull request
Dec 13, 2017
Try another approach to defer the termcodes. Seems less janky, but still not perfect. ref neovim#7664 ref neovim#7649 ref neovim#7664 ref 27f9b1c
justinmk
added a commit
to justinmk/neovim
that referenced
this pull request
Dec 13, 2017
With this implementation there is no "jank" during startup. Using the main_loop in any fashion is janky. Using only the TUI loop emits the termcodes too soon, or requires bad hacks like counting tui_flush invocations (9 seems to work). ref neovim#7664 ref neovim#7649 ref neovim#7664 ref 27f9b1c
justinmk
added a commit
to justinmk/neovim
that referenced
this pull request
Dec 15, 2017
- Revert timer-based approach. - Instead, call loop_poll_events() with a timeout in an "active" loop, to infer that "TUI startup activity has mostly finished", but also to enforce a mininum time (100 ms) before emitting "enable focus reporting" termcode. (If TUI startup takes longer than that minimum time, it's probably a slow environment anyways.) - Tickle `main_loop` by sending a dummy event. Without this, the initial "focus-gained" response from the terminal may not get processed until the user hits a key. ref neovim#7220 ref neovim#7664 ref neovim#7649 ref neovim#7664 ref 27f9b1c
justinmk
added a commit
to justinmk/neovim
that referenced
this pull request
Dec 16, 2017
- Revert timer-based approach. - Instead, call loop_poll_events() with a timeout in an "active" loop, to infer that "TUI startup activity has mostly finished", but also to enforce a mininum time (100 ms) before emitting "enable focus reporting" termcode. (If TUI startup takes longer than that minimum time, it's probably a slow environment anyways.) - Tickle `main_loop` by sending a dummy event. Without this, the initial "focus-gained" response from the terminal may not get processed until the user hits a key. ref neovim#7720 ref neovim#7664 ref neovim#7649 ref neovim#7664 ref 27f9b1c
justinmk
added a commit
to justinmk/neovim
that referenced
this pull request
Dec 16, 2017
- Revert timer-based approach. - Instead, call loop_poll_events() with a timeout in an "active" loop, to infer that "TUI startup activity has mostly finished", but also to enforce a mininum time (100 ms) before emitting "enable focus reporting" termcode. (If TUI startup takes longer than that minimum time, it's probably a slow environment anyways.) - Tickle `main_loop` by sending a dummy event. Without this, the initial "focus-gained" response from the terminal may not get processed until the user hits a key. ref neovim#7720 ref neovim#7664 ref neovim#7649 ref neovim#7664 ref 27f9b1c
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
For some reason, enabling focus reporting during terminal setup, causes
slow rendering during Nvim startup on tmux 2.3 with the tmux
focus-events
option enabled.To workaround that issue, this commit defers the request.
closes #7649
Using
script
to record the terminal session (andvterm-dump
topost-process the result):
BEFORE this commit:
AFTER this commit: