Skip to content

Feature Request: Allow Custom Editors To Gracefully Handle Diff Views #138525

Closed

Description

It would be awesome if custom editors could influence the diff view (or opt out of it).

These are examples where the default diff view does not really work:

Unfortunately, the individual custom editor only knows if it is readonly, but not if it is right or left of a diff view.

Related:

Activity

  1. Tyriar commented on Feb 18, 2022

    @Tyriar
    Contributor

    👍 hex editor and luna paint could also provide nicer diff experiences.

    image

  2. added this to the Backlog milestone on Dec 5, 2022
  3. fchen7i commented on Jan 30, 2023

    @fchen7i

    #171381 is slightly different. we want to use a new webview to do the compare

  4. starball5 commented on Jul 3, 2023

    @starball5

    It would be nice if the user could have control over this using the View: Reopen Editor With... or View: Reopen Editor With Text Editor commands (which is the case for the "compare files" feature). Even nicer might be if such a control (dropdown?) were available in the action bar (at the top right of the workbench).

    Related on Stack Overflow:

  5. zjffun commented on Dec 8, 2023

    @zjffun

    Set default editor for diff view

    We can use workbench.editorAssociations and configurationDefaults to set default editor for diff view, like:

    Text editor diff view:

    {
      "configurationDefaults": {
        "workbench.editorAssociations": {
          "{git,gitlens}:/**/*.{drawio,dio,dio.svg,drawio.svg}": "default",
        }
      }
    }

    Image preview diff view:

    {
      "configurationDefaults": {
        "workbench.editorAssociations": {
          "{git,gitlens}:/**/*.{bmp,dib,ico,png,jif,jpe,jpg,jpeg,tga,tpic,webp}": "imagePreview.previewEditor",
        }
      }
    }

    Set different custom editor for diff view and edit view

    {
      "configurationDefaults": {
        "workbench.editorAssociations": {
          "{git,gitlens}:/**/*.custom-ext": "custom-diff-editor",
        }
      },
      "customEditors": [
        {
          "viewType": "custom-editor",
          "displayName": "custom-editor",
          "selector": [
            {
              "filenamePattern": "*.custom-ext"
            }
          ],
          "priority": "default"
        },
        {
          "viewType": "custom-diff-editor",
          "displayName": "custom-diff-editor",
          "selector": [
            {
              "filenamePattern": "*.custom-ext"
            }
          ],
          "priority": "option"
        }
      ]
    }

    Example

    Edit view:
    Screen Shot 2023-12-09 at 03 17 13

    Diff view:
    Screen Shot 2023-12-09 at 03 16 57


    PS: Currently it seems some bug with configurationDefaults in VS Code 1.85.0, and it's fixed #194087 . configurationDefaults with workbench.editorAssociations should work fine use in VS Code 1.86.0, and now we can already use workbench.editorAssociations to test various scenes.

  6. cweijan commented on Mar 5, 2024

    @cweijan

    I found the final solution, which is surprisingly simple, and I think this issue can be closed.

    {
    	"viewType": "viewType",
    	"displayName": "Custom Editor",
    	"selector": [
    		{
    			"filenamePattern": "file:/**/*.ext"
    		}
    	]
    }
  7. hanjoosten commented on Mar 5, 2024

    @hanjoosten

    Weijan Chen (@cweijan) , Could you elaborate? Where should this json be configured?

  8. rsoika commented on Mar 5, 2024

    @rsoika

    Weijan Chen (@cweijan) thanks for your feedback. But I think this is not the solution for the problem. The configuration you mentioned is the general mapping for a file extension and your custom editor. We also use this in our Open-BPMN project to link .bpmn and .bpmn2 files with the editor.

    But the question is: How can I overwrite this editor linking for the Diff-Compare View? This is another editor type in vs-code that overtakes the default mappings.
    I am searching for a way to re-configure the Diff Editor in some way to show changes in bpmn file not graphical but in a text editor.

  9. Thomas-Grimmeisen commented on Mar 5, 2024

    @Thomas-Grimmeisen

    Weijan Chen (@cweijan) Thank you this is works like a charm for me!
    Ralph Soika (@rsoika) note the file:/ in the beginning of the filenamePattern - this is not present in the project you linked and was missing for me aswell.

  10. rsoika commented on Mar 5, 2024

    @rsoika

    Hi, thanks for your answer. It seems that I am not able to follow your suggestions here. My example was a deep configuration detail in my extension code itself. This is to associate my own extension (providing a custom editor) with a specific file extension. And this all works fine. So I can open a .bpmn file with the extension editor or a default text editor.

    But with this configuration in case of a GIT staging situation the Diff Editor View open two graphical editors. And this is what I want to avoid:

    grafik

    Jufeng Zhang (@zjffun) mentioned something like the following using the priority option:

      "customEditors": [
        {
          "viewType": "custom-editor",
          "displayName": "custom-editor",
          "selector": [
            {
              "filenamePattern": "*.custom-ext"
            }
          ],
          "priority": "default"
        },
        {
          "viewType": "custom-diff-editor",
          "displayName": "custom-diff-editor",
          "selector": [
            {
              "filenamePattern": "*.custom-ext"
            }
          ],
          "priority": "option"
        }

    But what I did not understand here is the view type custom-diff-editor ? Is this a vs-code editor feature that I just need to configure with the priority 'option' ? Or was this a suggestion for a possible solution in the future?

  11. 20 remaining items

  12. ulugbekna commented on Jun 10, 2026

    @ulugbekna
    Contributor

    Moved out to On Deck as a left-over on 1.124 milestone

  13. hediet commented on Jun 29, 2026

    @hediet
    MemberAuthor

    diffEditorAssociations can be used to opt out of using the custom editor as side-by-side diff view:

       // *.md opens in the custom markdown editor normally
      "workbench.editorAssociations": {
        "*.md": "vscode.markdown.editor"
      },
      // diffs of *.md use the default text diff editor instead - without this, the markdown editor would be shown side-by-side for diffs.
      "workbench.diffEditorAssociations": {
        "*.md": "default"
      }

    However, I think it would be better to have an opt-in instead of opt-out mechanism here, e.g.:

      "workbench.editorAssociations": {
        "*.md": { editor: "vscode.markdown.editor" } // only handle the editor view, not diff editor
      },

    ...otherwise every extension that provides a custom editor would need to reset the diff editor association.

  14. hediet commented on Jul 7, 2026

    @hediet
    MemberAuthor

    Covered by #324791.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

api-proposalcustom-editorsCustom editor API (webview based editors)feature-requestRequest for new features or functionalityverifiedVerification succeeded

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions