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

showTextDocument is not respecting preview: true if user has enablePreview disabled #149088

Closed
DavyLandman opened this issue May 9, 2022 · 3 comments · Fixed by #150552
Closed
Assignees
Labels
api insiders-released Patch has been released in VS Code Insiders workbench-editors Managing of editor widgets in workbench window
Milestone

Comments

@DavyLandman
Copy link

DavyLandman commented May 9, 2022

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

  • VS Code Version: 1.67.0
  • OS Version: Windows 10 10.0.19044

Steps to Reproduce:

  1. Set workbench.editor.enablePreview to false
  2. Inside an extension, open a TextDocument via the showTextDocument api, pass in the { preview: true } option.
  3. The new tab is not preview.
  4. Open another file via the showTextDocument api, and again a new tab is opened, non preview.

Either this is a bug, or the manual is incorrect:

An optional flag that controls if an editor-tab shows as preview. Preview tabs will be replaced and reused until set to stay - either explicitly or through editing. The default behaviour depends on the workbench.editor.enablePreview-setting.

I would understand (but be a bit sad) if the documentation is wrong, like that maybe it should say that this flag is only working when workbench.editor.enablePreview is true. I think the preferred behavior would be that the first time this is called, and no preview tab exists, a new one is allocated, and all the following showTextDocument calls with { preview: true } will use that new preview tab regardless of the user setting.

@DavyLandman DavyLandman changed the title showTextDocument is not respecting preview: true is user has enablePreview disabled showTextDocument is not respecting preview: true if user has enablePreview disabled May 9, 2022
@jrieken jrieken assigned bpasero and unassigned jrieken May 9, 2022
@DavyLandman
Copy link
Author

DavyLandman commented May 10, 2022

I've been reading the source a bit, if I understand correctly (i.e. I'm looking at the right instance of doOpenEditor), this line says that if enablePreview is set it will always be pinned, so the preview flag (which is translated to options?.pinned higher up in the stack) is ignored.

pinned: options?.sticky || !this.accessor.partOptions.enablePreview || editor.isDirty() || (options?.pinned ?? typeof options?.index === 'number' /* unless specified, prefer to pin when opening with index */) || (typeof options?.index === 'number' && this.model.isSticky(options.index)),

@bpasero
Copy link
Member

bpasero commented May 27, 2022

Yeah, if the user has disabled preview tabs, an extension cannot enforce it. We should probably document that.

@bpasero bpasero added this to the May 2022 milestone May 27, 2022
@bpasero bpasero added api workbench-editors Managing of editor widgets in workbench window labels May 27, 2022
bpasero added a commit that referenced this issue May 27, 2022
bpasero added a commit that referenced this issue May 27, 2022
@VSCodeTriageBot VSCodeTriageBot added the unreleased Patch has not yet been released in VS Code Insiders label May 27, 2022
@DavyLandman
Copy link
Author

Thank you for clarifying. I'll just have to tell users not to disable previews if they want this feature (of our extension) if they want to keep snappy cycles through files.

@VSCodeTriageBot VSCodeTriageBot added insiders-released Patch has been released in VS Code Insiders and removed unreleased Patch has not yet been released in VS Code Insiders labels May 30, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Jul 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api insiders-released Patch has been released in VS Code Insiders workbench-editors Managing of editor widgets in workbench window
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants