Skip to content
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

Clink async prompt #2556

Merged
merged 18 commits into from
Jul 18, 2021
Merged

Clink async prompt #2556

merged 18 commits into from
Jul 18, 2021

Conversation

chrisant996
Copy link
Contributor

Description

This PR adds support in Cmder for the new "asynchronous prompt filtering" in Clink v1.2.10 and higher. It should be forward/backward compatible with other versions of Clink.

Now the potentially slow git status (etc) commands are run in the background, so there's no waiting for the prompt to show up. When the background commands finish, the prompt gets refreshed. To avoid unnecessary flicker, the most recent results are cached so they can be used while waiting for new background commands to finish (switching repos or branches resets the cached results).

The new async prompt filtering is enabled by default in Clink, but prompt filters must opt in to use it (which is what this PR does for Cmder's git prompt). It can be turned off via clink set prompt.async false. See Asynchronous Prompt Filtering for more info.

Merge Notes

This PR is based on the pending PR #2549. When applied after #2549 is committed, I expect this PR should encounter few-or-no merge conflicts. But if it does encounter merge conflicts, let me know and I can resolve them.

Test Notes

  • Tested Cmder 1.3.18 with this change and Clink v1.1.45 (what it currently includes -- which is still a pre-release build of Clink).
  • Tested Cmder 1.3.18 with this change and Clink v1.2.10 (latest release build).
    • Tested with prompt.async setting true (the default).
    • Tested with prompt.async setting false.

Everything looks good to me.

ian-craig and others added 15 commits May 20, 2021 17:53
`git status` and `git diff` can be slow in large repos.  Clink v1.2.10
and higher support using Lua coroutines to do expensive parts of prompt
filtering in the background.  When the expensive parts complete, the
prompt gets refreshed.

This means even large repos can have fast prompts PLUS git status all
the time!

This change should be backward/forward compatible with both older and
newer versions of Clink (of course only newer versions will gain the
benefit).
Setting `prompt_overrideGitStatusOptIn = true` will override the
`cmder.status` and `cmder.cmdstatus` git config settings and run the git
prompt status commands in the background.  But it only takes effect when
using Clink v1.2.10, since that's required in order to run prompt update
commands in the background.
The Cmder prompt normally includes version control info, which involves
running some potentially expensive commands.  The cmder-powerline-prompt
project (and maybe other projects) replaces the Cmder prompt and runs
the same potentially expensive commands -- so expensive commands get run
twice!

This change makes it possible for the user and/or other scripts to
disable the version control part of the built-in Cmder prompt.

https://github.com/chrisant996/cmder-powerline-prompt
It was less clear before, and it also accidentally took effect when
the `prompt.async` Clink setting was off.
@Stanzilla Stanzilla merged commit b8760e4 into cmderdev:master Jul 18, 2021
@daxgames
Copy link
Member

@Stanzilla thanks I was just starting to look at this yesterday.

@daxgames
Copy link
Member

I am sorry this took me so long to look at this PR. This is an awesome feature, speeds up the prompt to the point the delay is all but imperceptible! Thank you @chrisant996 for this and all the work you have done on revitalizing clink

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants