sunaku / home

🏡 My $HOME directory (dot files & bin scripts)
https://sunaku.github.io/about.html#unix-shell-environment
139 stars 16 forks source link

Delayed appearance of git symbols when using async #4

Closed tmpm697 closed 3 years ago

tmpm697 commented 4 years ago

I use your latest commit that enable async - thanks for that, but symbols that display for e.g: when there's file added to repo or file under repo change delayed to appear when spawn new shell.

Steps to produce:

  1. clone a random repo
  2. cd to repo; modify file, touch new file ..etc
  3. in tmux create new pane ( my tmux and zsh will remember last directory and use it for new spawned pane's shell)
  4. you see delayed of new shell when display git's symbols, for e.g: user@localhost ?>_>% user@localhost will display very fast but git's symbol ?>_> has some delay when display.

I believe this due to we do async git but did not async other part of prompt and sync all of parts, what do you think?

sunaku commented 4 years ago

That is correct. :heavy_check_mark: Since vcs_info is calculated asynchronously, the ${vcs_info_msg_0_} variable in the prompt has no initial value and is therefore rendered as nothing. :running_man: Later, when the vcs_info calculation job is finished, it triggers a chain reaction that populates the ${vcs_info_msg_0_} variable and re-renders the prompt. :sparkles: Now, the calculated vcs_info output suddenly appears in the prompt.

PROMPT='...${vcs_info_msg_0_}...'
tmpm697 commented 4 years ago

Is there away to sync all parts of prompt or make all parts appears at the same time? Sorin prompt seem achieved this. @sunaku

sunaku commented 3 years ago

Wouldn't making all parts appear at the same time defeat the purpose of async? :thinking: You'd essentially have to wait for the slowest part (i.e. vcs_info) to finish before displaying the prompt (so that all parts appear at the same time), and this would slow it down.

tmpm697 commented 3 years ago

Make sense.