![](/img/trans.png)
[英]Code highlighting in Peek Definition window of Visual Studio Code
[英]Disable peek in Visual Studio Code
有沒有辦法在Visual Studio代碼中禁用ctrl-click'peek'功能? 理想情況下,我想按住Ctrl鍵單擊以在新選項卡中打開包含定義的文件。
編輯 :我提交了一個問題 ,至少讓它不那么混亂。 顯然我的術語有些錯誤。
澄清一下,有兩個動作:
他們的行為如下:
PD,多種定義
GtD,單一定義
所有這些都很好,除了最后一個。 做這兩件事會導致真正多余且令人困惑的UI,如下所示:
應該有辦法讓這些行為之一:
要么:
我已經發出拉取請求來修復此https://github.com/Microsoft/vscode/pull/68023 ,但在此之前,這是一個修復VSCode安裝文件的臨時修復程序。 您需要重新應用每個更新。
通過此修復,Ctrl +單擊將:
弄清楚需要修補的功能是什么樣的。 方法是DefinitionAction.prototype._onResult(editorService, editor, model)
轉到VSCode安裝目錄。 %LocalAppData%\\Programs\\Microsoft VS Code
並右鍵單擊並打開VSCode中的目錄,以便我們可以使用VSCode的搜索功能搜索每個文件中的文本。
搜索_onResult
並評估每個結果,檢查簽名和正文是否符合我們在步驟1中看到的功能所期望的結果。
_openReference
就在附近。 用它來縮小搜索范圍。 workbench.main.js
第2454
行找到了它。 使用括號匹配查找結尾或知道它在t.prototype._openReference
之前立即t.prototype._openReference
格式化時的函數如下(async func被編譯為statemachine,這就是為什么它看起來不像源打字稿):
t.prototype._onResult = function (e, t, r) { return i(this, void 0, void 0, function () { var i, s, a; return n(this, function (n) { switch (n.label) { case 0: return i = r.getAriaMessage(), o.alert(i), this._configuration.openInPeek ? (this._openInPeek(e, t, r), [3, 3]) : [3, 1]; case 1: return s = r.nearestReference(t.getModel().uri, t.getPosition()), [4, this._openReference(t, e, s, this._configuration.openToSide)]; case 2: (a = n.sent()) && r.references.length > 1 ? this._openInPeek(e, a, r) : r.dispose(), n.label = 3; case 3: return [2] } }) }) }
將該功能替換為以下 (如果使用相同版本)或格式化並編輯您發現的與此示例類似的功能。 請注意, o
變量是全局\\窗口對象,可能會發生變化。
t.prototype._onResult = function (e, t, r) { return i(this, void 0, void 0, function () { return n(this, function (n) { switch (n.label) { case 0: return r.getAriaMessage(), o.alert(r.getAriaMessage()), this._configuration.openInPeek || r.references.length > 1 ? (this._openInPeek(e, t, r), [3, 3]) : [3, 1]; case 1: return [4, this._openReference(t, e, r.nearestReference(t.getModel().uri, t.getPosition()), this._configuration.openToSide)]; case 2: r.dispose(), n.label = 3; case 3: return [2] } }) }) }
啟動VSCode。 您將獲得Your Code installation appears to be corrupt. Please reinstall
Your Code installation appears to be corrupt. Please reinstall
。 只需點擊齒輪圖標,然后單擊Don't Show Again.
我試圖找到一個解決方法來改變CMD的行為+點擊進入實施,但似乎還沒有解決方案呢?
VSCode文檔默認顯示其設置,無需修改它即可轉到定義: https ://code.visualstudio.com/docs/editor/editingevolved
在我的機器(Mac)上,如果我按下方法上的CMD + Click或F12 ,它將引導我查看定義的Peek視圖,但CMD + F12會指示我執行而不會出現。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.