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

Fix to force refreshing suggestion in the inline view when plugin is in use #3644

Merged
merged 2 commits into from Apr 7, 2023

Conversation

daxian-dbw
Copy link
Member

@daxian-dbw daxian-dbw commented Apr 4, 2023

PR Summary

Fix to force refreshing suggestion in the inline view when plugin is in use, even if the current history suggestion can still apply to the new input.

Scenario:
When the prediction source is HistoryAndPlugin, we favor plugin results over history results in the inline view. For an command-line input, if the plugin doesn't return anything, the history result will be used.

Today, when an inline view prediction is displayed, if you keep typing and the existing suggestion can still apply to the resulted new input, PSReadLine will continue to use the existing suggestion text instead of refreshing the suggestion.
So, when the history suggestion is used for inline view, if the new input resulted from your typing can still fit in the existing history suggestion, the plugin won't be triggered, even though it now may return more relevant result.

This PR fixes the above issue:

  • when the prediction source is History only, the behavior is not changed
  • when the prediction source is HistoryAndPlugin
    • the existing suggestion is from a plugin, then the current behavior is not changed -- if the existing suggestion can still apply to the new input, PSReadLine continues to use it instead of refreshing suggestion.
    • the existing suggestion is from history, then new input will force refreshing the suggestion, unless the new input is resulted by the user accepting the next word of the existing history suggestion.

PR Checklist

  • PR has a meaningful title
    • Use the present tense and imperative mood when describing your changes
  • Summarized changes
  • Make sure you've added one or more new tests
  • Make sure you've tested these changes in terminals that PowerShell is commonly used in (i.e. conhost.exe, Windows Terminal, Visual Studio Code Integrated Terminal, etc.)
  • User-facing changes
    • Not Applicable
    • OR
    • Documentation needed at PowerShell-Docs
      • Doc Issue filed:
Microsoft Reviewers: Open in CodeFlow

@daxian-dbw daxian-dbw self-assigned this Apr 4, 2023
Copy link
Member

@andyleejordan andyleejordan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for the thorough commentary and tests, made it much easier to follow and double-check.

@daxian-dbw daxian-dbw merged commit 2fb3c33 into PowerShell:master Apr 7, 2023
1 check passed
@daxian-dbw daxian-dbw deleted the inline branch April 7, 2023 05:07
@ghost
Copy link

ghost commented May 3, 2023

🎉 v2.3.1-beta1 has been released which incorporates this pull request. 🎉

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.

None yet

2 participants