fwd-i-search: _ 的含义是什么?为什么它出现在 PowerShell 中?

use*_*709 6 powershell visual-studio-code

如前所述,我刚刚运行了一个相当长的程序,它完成了,通常的提示出现在终端中(PS C:\\Users\\\xe2\x80\xa6\\program_name),然后几分钟后,fwd-i-search: _出现在下一行。failed-fwd-i-search我可以在它旁边打字,当我打字时它就会改变。Can\xe2\x80\x99t 似乎可以执行更多程序,需要重新启动 IDE 才能使其消失。我\xe2\x80\x99m 只是想知道这个命令的作用以及为什么它会自发地出现?

\n

我尝试过谷歌搜索但无济于事。“正向搜索”一词在 Google 搜索结果中出现很多,但指的是 I\xe2\x80\x99m 未运行的 Linux 系统。这是该问题在 6 个月内第二次出现,所以这种情况并不常见,但我想知道原因可能是什么。

\n

我在 VS Code 中使用 PowerShell 是为了它的价值。

\n

sta*_*all 3

如果您已经安装了PSReadline 模块,或者您正在使用VS Code 的PowerShell 扩展(它捆绑了 PSReadLine(另请参阅其powershell.integratedConsole.useLegacyReadLine 设置)),这可能就是原因。这是历史搜索功能。它允许您搜索以前运行过的命令并重新运行它们(更常用的命令是反向搜索)。您可以在GNU Readline 文档中找到有关含义reverse-search-historyforward-search-history含义的相关文档。在 Readline 中,您始终位于历史记录中的“行”,并且可以使用各种命令及其键盘绑定在历史记录行之间导航。

相关按键绑定代码在PSReadline函数中SetDefaultWindowsBindings

{ Keys.CtrlS,                  MakeKeyHandler(ForwardSearchHistory,      "ForwardSearchHistory") },
Run Code Online (Sandbox Code Playgroud)

以及类中相关的提示字符串定义代码PSConsoleReadLine

private const string _forwardISearchPrompt = "fwd-i-search: ";
Run Code Online (Sandbox Code Playgroud)

您可以在https://learn.microsoft.com/en-us/powershell/module/psreadline/about/about_psreadlinehttps://github.com/PowerShell/PSReadLine中阅读有关 PSReadline 的更多信息。

您应该能够按escctrl+c退出/关闭搜索提示。可以使用 配置 PSReadline 的键绑定Set-PSReadLineKeyHandler。有关更多信息,请参阅自述文件