Skip to content

Handle keyboard-invoked activateFromFiles without selectedFiles - #43

Draft
a-r-j with Copilot wants to merge 3 commits into
mainfrom
copilot/fix-keyboard-shortcut-error
Draft

a-r-j with Copilot wants to merge 3 commits into
mainfrom
copilot/fix-keyboard-shortcut-error

Conversation

Copilot AI commented May 22, 2026 •

Copy link
Copy Markdown
Contributor

Keyboard shortcuts can invoke protein-viewer.activateFromFiles without the Explorer multi-select payload, causing undefined to flow into file rendering and crash on .map(...). This change makes command argument handling resilient across invocation paths (context menu vs keybinding).

  • Command input normalization

    • Added getFileUrisToOpen(fileUri, selectedFiles, activeEditorUri) to resolve files in a strict fallback order:
      1. selectedFiles (Explorer multi-select)
      2. command fileUri
      3. active editor document URI
      4. empty list
  • Crash guard at panel boundary

    • Updated ProteinViewerPanel.renderFromFiles(...) to short-circuit on empty input and surface a user-facing error instead of dereferencing undefined.
  • Type and call-site hardening

    • Updated file-list parameters to accept readonly/optional URI arrays where appropriate.
    • Removed reliance on assumptions that command args are always present in a fixed shape.
  • Focused regression coverage

    • Added tests for URI resolution behavior covering:
      • selected-files precedence
      • single-file command fallback
      • active-editor fallback
      • empty-input result
export function getFileUrisToOpen(
  fileUri: vscode.Uri | undefined,
  selectedFiles: readonly vscode.Uri[] | undefined,
  activeEditorUri: vscode.Uri | undefined
): vscode.Uri[] {
  if (selectedFiles?.length) return [...selectedFiles];
  if (fileUri) return [fileUri];
  if (activeEditorUri) return [activeEditorUri];
  return [];
}
Copilot AI linked an issue May 22, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Fix keyboard shortcut for launching protein viewer May 22, 2026
Copilot AI requested a review from a-r-j May 22, 2026 20:29
Copilot finished work on behalf of a-r-j May 22, 2026 20:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants