Skip to content

Diff tabs opened from the Source Control panel no longer in preview mode #26184

Closed

Description

@cateyes99
  • VSCode Version: 1.12.1
  • OS Version: OS X EI Capitan 10.11.3

Steps to Reproduce:

  1. Open some project from GitHub.
  2. Make some changes to a file A.cs, and save it.

3.a Stay on the editor of A.cs, and click the button of Open Changes on the top right corner above the editor.
4.a A diff tab opened to show the difference between the changed A.cs and the version in GitHub. Before version 1.12, this diff tab will be open in the preview mode (the tab title font is in italic), now the new diff tab is just a normal tab.

3.b Open the Source Control panel, click A.cs.
4.b A diff tab opened to show the difference between the changed A.cs and the version in GitHub. Before version 1.12, this diff tab will be open in the preview mode (the tab title font is in italic), now the new diff tab is just a normal tab.

  1. If I have 50 files changed, and iterate the changes in the 50 files from Source Control panel, it will open 50 diff tabs for me! This new behaviour isn't very desired. The old behaviour in the previous versions is much more convenient and consistent with opening files from the Explorer panel.

Activity

  1. changed the title [-]Diff tabs opened from `Source Control` no longer in preview mode[/-] [+]Diff tabs opened from the `Source Control` panel no longer in preview mode[/+] on May 8, 2017
  2. eamodio commented on May 8, 2017

    @eamodio
    Contributor
  3. joaomoreno commented on May 8, 2017

    @joaomoreno
    Contributor

    cc Johannes Rieken (@jrieken) already 4 users mentioned this

  4. added
    bug
    on May 8, 2017
  5. jrieken commented on May 8, 2017

    @jrieken
    Contributor

    This was to align the behaviour of our various open-calls. João Moreno (@joaomoreno) you do have an option tho, simply set preview to true and everything is back to normal

  6. bpasero commented on May 9, 2017

    @bpasero
    Contributor

    I think the extension should not decide to set the preview flag unless it really wants to make sure that something does not open as preview (e.g. a use case I can see is to open a playground to the side of the current editor that should not go away too easily).

    The workbench should deal with the preview flag, otherwise settings like "workbench.editor.enablePreview": false are ignored, which is bad.

  7. bdinesh commented on May 9, 2017

    @bdinesh

    Johannes Rieken (@jrieken) I have set "workbench.editor.enablePreview": true in user settings but no luck. Is there any other setting to be set explicitly?

  8. jrieken commented on May 10, 2017

    @jrieken
    Contributor

    This isn't about the setting Dinesh Bogolu (@bdinesh). Foremost extensions can express their intent when showing a text document (preview or not). Unsure how the setting plays into that, but I have a feeling that the editor service should use it and simply overrule the API choice. Correct Benjamin Pasero (@bpasero) or are there editors that must open as preview despite have that setting which blocks putting this into the service?

  9. bpasero commented on May 10, 2017

    @bpasero
    Contributor

    Johannes Rieken (@jrieken) João Moreno (@joaomoreno) today we have two settings that play a role to decide if an editor should open as preview or not:

    • workbench.editor.enablePreview (default: true)
    • workbench.editor.enablePreviewFromQuickOpen (default: true)

    If these settings are configured by default, in most cases we open files in preview (e.g. click in explorer, open from quick open).

    However, there are still some user interactions that can lead to not using preview after all independent from the setting:

    • double click in the explorer
    • opening a dirty file
    • moving a file from the explorer

    If the workbench.editor.enablePreview setting is configured to be false you will never see an editor as preview no matter how the user configured it from the API.

    If the workbench.editor.enablePreviewFromQuickOpen setting is configured to be false, it only impacts editors that open from quick open but nothing else.

    My understanding is that we added new API for TextDocumentShowOptions to control if a document opens as preview or not. However, we are not having this option from our vscode.diff command, and as such there we now hardcode pinned: true. Wouldn't it best we do not set pinned at all for any editor we open from extensions and let the extension decide this? For example, we could add support for the vscode.diff command to define similar TextDocumentShowOptions and then the GIT extension can actually decide to open pinned or not based on user interaction (e.g. double click vs. single click).

  10. jrieken commented on May 10, 2017

    @jrieken
    Contributor

    However, we are not having this option from our vscode.diff command, and as such there we now hardcode pinned: true.

    No, that isn't correct. We have added that option when adding the option for showing a text document. The change that happened is that both are now aligned wrt the default, which is 'pinned'. The diff-command used to be different here and because it is less official got aligned with the show-function. To get to old behaviour you need to pass {preview: true} when calling the diff-command.

  11. eamodio commented on May 10, 2017

    @eamodio
    Contributor

    Before these changes extensions could do the following (at least as I've observed them):

    commands.executeCommand('vscode.open' ...) - would always open the document in preview (not pinned) and steal focus
    commands.executeCommand('vscode.diff' ...) - would always open the diff in preview (not pinned) and steal focus
    window.showTextDocument(...) - would always open the document not in preview (pinned) and you could control the focus

    After these changes:
    commands.executeCommand('vscode.open' ...) - unchanged since it is deprecated
    commands.executeCommand('vscode.diff' ...) - opens the diff in not in preview (pinned) by default (to align with the default of showTextDocument) and takes the new TextDocumentShowOptions to control preview, focus, column, etc
    window.showTextDocument(...) - opens the document in not in preview (pinned) by default and takes the new TextDocumentShowOptions to control preview, focus, column, etc

    So now the default behavior of both is aligned and both provide the same options.

    Hope that helps and makes sense.

  12. bpasero commented on May 12, 2017

    @bpasero
    Contributor

    Johannes Rieken (@jrieken) Eric Amodio (@eamodio) to me the only right way of fixing this is to not set pinned option in showTextDocument and vscode.diff unless the caller is explicitly setting this option. Otherwise there is no way to get the default behaviour we have everywhere else where the settings of the user are being looked at.

    Otherwise, the only way of fixing it for the git extension is to read the user settings (specifically workbench.editor.enablePreview) and then make the decision of setting pinned or not based on that. But basically any extension that uses the vscode.diff command or the showTextDocument would have to do that if they wanted the default behaviour. I would change it and let those extensions adopt the pinned option that really want the editor to open pinned.

  13. 5 remaining items

  14. joaomoreno commented on May 24, 2017

    @joaomoreno
    Contributor

    Turns out I was wrong.

  15. eamodio commented on May 24, 2017

    @eamodio
    Contributor

    João Moreno (@joaomoreno) while that commit fixed it for the SCM/Git case, it didn't address Benjamin Pasero (@bpasero)'s concerns above -- so should this be re-opened or should that be moved into a separate issue?

  16. added a commit that references this issue on May 26, 2017
    a0a1b9e
  17. added a commit that references this issue on Jun 20, 2017
  18. added a commit that references this issue on Jul 6, 2017
  19. locked and limited conversation to collaborators on Nov 18, 2017
  20. added 2 commits that reference this issue on Sep 6, 2026
    0450621
    ed98524
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

buggitverified

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions