gpt4 book ai didi

visual-studio-code - 搜索(在文件中查找)键绑定(bind)可以带参数,workbench.view.search 不能 - 其他区别?

转载 作者:行者123 更新时间:2023-12-04 15:25:52 28 4
gpt4 key购买 nike

我只想知道 workbench.action.findInFilesworkbench.view.search 命令之间的区别。两者都用于访问跨文件搜索面板。

我猜 workbench.action.findInFilesworkbench.view.search 的更新版本,因为我找到了 'findInFiles' accepts parametersview.search 没有。

引用:https://github.com/microsoft/vscode/blob/cadabab73fef89fe0c4bfe23b5a33cd58e39ea9c/src/vs/workbench/services/search/common/search.ts#L24

最佳答案

我认为您捕获了唯一真正的区别。它们都有相同的默认键绑定(bind),但 view 版本确实有一个 context 参数:

!searchViewletVisible

所以它实际上只是在不可见时显示搜索面板。但是 findInFiles 版本也会使搜索面板可见。唯一真正的区别是接受争论的能力——我认为很少有人知道这一点。

正如您所指出的,findInFiles 版本可以带参数——我以前不知道!!所以值得展示如何。像这样:

  {
"key": "ctrl+shift+f", // whatever keybinding you wish
"command": "workbench.action.findInFiles",
"args": {

"query": "${selectedText}", // variables don't work
"replace": "that's $1 swell",
"triggerSearch": true, // seems to be the default
"filesToInclude": "${relativeFileDirname}", // no variables
"preserveCase": true,
"useExcludeSettingsAndIgnoreFiles": false,
"isRegex": true,
"isCaseSensitive": true,
"matchWholeWord": true,
"filesToExclude": "./*.css"
}
},

workbench.view.search 可用参数的完整列表:

   "query": "",
"regexp": "",
"wholeWord": "",
"caseSensitive": "",
"includes": "",
"excludes": "",
"showIncludesExcludes": "",
"useIgnores": "",
"contextLines": 0,
"triggerSearch": "",
"focusResults":

上面的 args 列表正在转换为下面的列表(参见 https://github.com/microsoft/vscode/commit/2fdc8c336c601e385fadfaa1802cdc67fea96241 )以与 findInFiles 命令保持一致。我假设旧的 args 会工作一段时间,但新的 args 在 Insiders' Build v1.51 中,所以应该很快就会稳定。

  "query": ""
"isRegexp": true,
"isCaseSensitive": false,
"matchWholeWord": true,
"filesToInclude": "",
"filesToExclude": "",
"showIncludesExcludes": false,
"useExcludeSettingsAndIgnoreFiles": true,
"contextLines": 2,
"triggerSearch": true,
"focusResults": true

如果您有一个常用的搜索/替换,这可能很有值(value)并且可以分配给唯一的键绑定(bind)。


workbench.view.search 不能接受预设参数,但是 search.action.openNewEditor 可以!参见 https://stackoverflow.com/a/62207896/836330了解更多。

关于visual-studio-code - 搜索(在文件中查找)键绑定(bind)可以带参数,workbench.view.search 不能 - 其他区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62251045/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com