zed-industries / zed

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
https://zed.dev
Other
50.94k stars 3.16k forks source link

Opening file from file menu on click event. #18017

Open Nevoral opened 2 months ago

Nevoral commented 2 months ago

Check for existing issues

Describe the bug / provide steps to reproduce it

Sorry, I used AI to better formulate my thoughts; it's not autogenerated.

When using the editor with a split view, the current behavior when opening a file from the File menu is suboptimal. Here's a detailed description of the problem and a proposed solution:

Current Behavior

  1. Environment Setup:

    • The editor is split into two halves (panels).
    • Each half contains its own tab bar displaying open files.
  2. Reproduction Steps:

    • You are actively working in one of the panels (let's call it Panel A).
    • You click to open a file from the File menu while Panel A is active.
  3. Observed Issue:

    • The newly selected file opens in Panel A, regardless of whether it is already open in the other panel (Panel B).
    • This leads to the same file being opened in multiple panels unnecessarily.

Proposed Solution

The editor should adopt the following behavior instead:

  1. Open File Logic:

    • Check if the File is Already Open: When a file is selected from the File menu, the editor should first check if this file is already open in any of the panels.
    • If File is Not Open: If the file isn't open in any panel, it should open in the currently active panel (Panel A in this case).
    • If File is Open in Another Panel: If the file is already open in another panel (Panel B), the editor should bring focus to that panel and activate the tab containing the file, without opening another instance in the active panel.
  2. Shortcut for Opening Multiple Instances:

    • Current Functionality as a Shortcut: The current behavior of opening the same file in several panels should not be the default, but it can remain as a secondary option accessed via a specific shortcut (which is already in place).

Benefits

By implementing this proposed solution, the editor will provide a more intuitive and efficient user experience, particularly when managing multiple files across split panels.

Environment

Zed: v0.153.4 (Zed Preview) OS: Linux X11 ubuntu 24.04 Memory: 31.2 GiB Architecture: x86_64 GPU: NVIDIA GeForce RTX 3070 Ti || NVIDIA || 535.183.01

If applicable, add mockups / screenshots to help explain present your vision of the feature

No response

If applicable, attach your Zed.log file to this issue.

Zed.log


notpeter commented 2 months ago

You gotta do better than this when submitting issues, I felt my brain melting while reading. Please don't do this in the future. It took me 15 minutes to get here, but I think your 355 words could have been replaced with 64:

Steps to reproduce:
1. Open FileABC from the project panel. 
2. Split (cmd-k, cmd-right) -- same file in left/right panes
3. Open FileXYZ from the project panel (opens in right pane)
4. Change focus to the left pane
5. Open FileXYZ from the project panel again

Observed behavior: New tab with FileXYZ in left pane
Desired behavior: Change focus to FileXYZ in right pane

Is this correct?

This would match VSCode behavior.