-
-
Notifications
You must be signed in to change notification settings - Fork 809
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
initial code to show how async 'git status' prompt can work #104
Closed
Conversation
This file contains 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
- while it works well for me in my testing, this is meant more as a basis of discussion for 1) whether it makes sense for this to be in posh-git and 2) if so, what it should look like. This version intentionally doesn't refactor out common code with the synchronous path since the goal is validating/rejecting the idea instead of the particular impl
Thanks, James! I think an ideal setup might be to combine a file watcher (to prevent unnecessary calls) with an opt-in async prompt for slow repositories (we could even automatically switch if status is detected to take longer than some threshold). However, my first attempt to use this leaves me stuck at:
Relevant settings:
Anything you'd just suggest I check before I dive in to debug? |
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.
This is intended more for discussion than being merged 'as-is' - if/when it were to be merged, the common bits of functionality in the sync and async code paths should be factored out (and maybe the sync case being the async code path with an added wait on the process to exit, but that's not really relevant right now).
The approach taken here intentionally doesn't use any of the other work (like caching status, filesystemwatcher, etc) - not that it couldn't be used with those, but more to keep it as simple as possible for now for a hopefully smaller diff and easier discussion about whether it's a good fit for posh-git.
The logic/data flow isn't much different than the existing synchronous prompt - it's controlled in this diff by a new bool in the GitPromptSettings (EnableAsyncFileStatus) for easier testing and comparison.
The key 'breakthrough' WRT earlier discussions in issues like #52 was finding that the RawUI interface didn't actually require cursor location manipulation in order to write to the screen buffer in a place other than wherever the cursor was already located. Instead, it supports writing a 2d rectangle to the buffer at a specified coordinate. This means we don't have to worry about the various bad states we might get into if we were manually moving the cursor and writing strings out to the buffer while the user was typing at their prompt (yay!)
PSHostRawUserInterface.SetBufferContents Method (Coordinates, BufferCell[,])
The main new/entry function to look at it is Write-GitStatusPromptAsync in the new file GitAsyncPrompt.ps1
in the case of EnableAsyncFileStatus -eq $true (and we're in a repo that hasn't been disabled), it does:
IME it runs 'fast enough' that even if it hit enter ~10 times, resulting in ~10 git status calls running, they all still complete very quickly (and they each write to their correct screen buffer location).
Does the idea/approach make sense for posh-git?
Thanks!
Related issues about perf of git status: