vscode icon indicating copy to clipboard operation
vscode copied to clipboard

Docs > when clause contexts > view identifiers: workbench.view.scm is not correct, workbench.scm is

Open Yohnny777 opened this issue 2 years ago • 1 comments

Does this issue occur when all extensions are disabled?: Yes

  • VS Code Version: 1.73.1, Electron 19.0.17, Node 16.14.2, Chromium 102.0.5005.167,
  • OS Version: Windows_NT x64 10.0.22000

Referring to this: https://code.visualstudio.com/api/references/when-clause-contexts#activefocused-view-or-panel-when-clause-context

When clause contexts' Source Control's view identifier is not workbench.view.scm as docs state, but is actually workbench.scm. I discovered this while writing key binding with focusedView == workbench.view.scm, it would never be true, but it works correctly with focusedView == workbench.scm. I got this value from Developer: Inspect context keys command.

Steps to Reproduce:

  1. Try to create any keybind with focusedView == 'workbench.view.scm', shouldn't work Try adding this for example:
  {
    "key": "escape",
    "command": "workbench.explorer.fileView.focus",
    "when": "focusedView == workbench.view.scm"
  },
  1. Change when clause to focusedView == 'workbench.scm' should work now
  {
    "key": "escape",
    "command": "workbench.explorer.fileView.focus",
    "when": "focusedView == workbench.scm"
  },

Looks like a "typo" while writing the docs, or internally view identifiers changed and docs were not updated.

I did not check if other IDs are correct, like workbench.view.search etc, they might be wrong in the same way as well.

Yohnny777 avatar Nov 17 '22 23:11 Yohnny777

Adding @gregvanl, @sandy081, @sbatten to confirm whether this is indeed a documentation bug or an issue with setting focusedView.

lszomoru avatar Dec 08 '22 15:12 lszomoru

This seems to be a doc bug - because I see the view id in our code is workbench.scmhere - https://github.com/microsoft/vscode/blob/f126d786635872b21ff0890c9e7108fcf54e2ab3/src/vs/workbench/contrib/scm/common/scm.ts#L18

sandy081 avatar Dec 12 '22 10:12 sandy081

export const VIEWLET_ID = 'workbench.view.scm';
export const VIEW_PANE_ID = 'workbench.scm';

Yeah, someone must've mistaken these two

Yohnny777 avatar Dec 13 '22 23:12 Yohnny777

@sandy081, what confuses me is that other identifiers on that page also point to viewlets.

https://github.com/microsoft/vscode/blob/8b939ad54bcd614386e16ee0a84f858356ceb036/src/vs/workbench/contrib/extensions/common/extensions.ts#L22-L23

Could there be other identifiers on that page that are incorrect?

lszomoru avatar Dec 14 '22 10:12 lszomoru

Agree with Lad, I haven't made progress on this nor the vscode-docs issue and PR until I understand when each ID should be used and whether other views have separate view and pane IDs.

workbench.view.blah is usually the command ID for opening the view, for example:

image

gregvanl avatar Dec 14 '22 16:12 gregvanl

I see the confusion here - we have view containers (viewlets/panels) and views. There are following three contexts

  • activeViewlet - which expects viewlet/view container id
  • activePanel - which expects panel/view container id
  • focusedView - which expects view id

Probably we shall update the doc by listing viewlets and views ids.

sandy081 avatar Dec 20 '22 19:12 sandy081

Thanks @sandy081 for the clarifications. Could you please work with @gregvanl to update the page? Thank you!

lszomoru avatar Dec 20 '22 19:12 lszomoru