Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jul 10, 2025

The preview option was being ignored when using vscode.commands.executeCommand('vscode.openWith', uri, editorId, {preview: true}). This caused custom editors to always open in pinned mode (tab not italicized) instead of respecting the user's preview preference.

Problem

When calling:

vscode.commands.executeCommand('vscode.openWith', uri, 'hexEditor.hexedit', {preview: true});

The tab would always appear pinned (not italicized) instead of in preview mode (italicized), indicating that the preview: true option was being ignored.

Root Cause

In src/vs/workbench/browser/parts/editor/editorCommands.ts, the API_OPEN_WITH_EDITOR_COMMAND_ID command implementation had a hardcoded pinned: true that was overriding user preferences:

// Before fix
{ pinned: true, ...optionsArg, override: id }

Even though the user's {preview: true} gets correctly converted to {pinned: false} by the type converter, the hardcoded pinned: true was preventing this preference from being respected.

Solution

Removed the hardcoded pinned: true to allow user preferences to take precedence:

// After fix
{ ...optionsArg, override: id }

This makes the openWith command consistent with the regular open command, which doesn't have a hardcoded pinned value.

Testing

Added comprehensive unit tests in src/vs/workbench/test/browser/parts/editor/editorCommandsOpenWith.test.ts covering:

  • Preview mode when preview: true is specified
  • Pinned mode when preview: false is specified
  • Default behavior when no options are provided

Impact

This fix ensures that:

  • Extensions can properly control preview behavior for custom editors
  • User preferences are respected consistently across all editor opening commands
  • The behavior matches user expectations as described in the original issue

The change is minimal and surgical, affecting only the specific problematic code path without impacting other functionality.

Fixes #235535.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • electronjs.org
    • Triggering command: node-gyp (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: mjbvz <12821956+mjbvz@users.noreply.github.com>
Copilot AI changed the title [WIP] preview flag not respected for custom editor Fix preview flag not being respected for custom editor openWith command Jul 10, 2025
Copilot AI requested a review from mjbvz July 10, 2025 22:33
Copilot finished work on behalf of mjbvz July 10, 2025 22:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

preview flag not respected for custom editor

2 participants