Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Editor::KillRingCut support for multiple lines? (emacs) #22490

Open
1 task done
pchalasani opened this issue Dec 29, 2024 · 2 comments
Open
1 task done

Editor::KillRingCut support for multiple lines? (emacs) #22490

pchalasani opened this issue Dec 29, 2024 · 2 comments
Labels
editor Feedback for code editing, formatting, editor iterations, etc enhancement [core label]

Comments

@pchalasani
Copy link

pchalasani commented Dec 29, 2024

Check for existing issues

  • Completed

Describe the bug / provide steps to reproduce it

I noticed that emacs-like "kill-ring" cut/yank was added recently. My base keymap is Jetbrains and in my custom ~/.config/zed/keymap.json I have this:

 {
    "context": "Editor",
    "use_key_equivalents": true,    
    "bindings": {
      "ctrl-y": "editor::KillRingYank", 
      "ctrl-k": "editor::KillRingCut"      
    }
  },

However I'm finding that Ctrl-k only adds a single like to the kill ring, i.e. when I consecutively kill multiple lines, and then yank with Ctrl-y, I just get the last line killed.

Not sure if I need to set up anything else for this to work.

Zed Version and System Specs

Zed: v0.166.1 (Zed)
OS: macOS 15.0.0
Memory: 64 GiB
Architecture: aarch64

If applicable, add screenshots or screencasts of the incorrect state / behavior

No response

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

Zed.log

@pchalasani pchalasani added admin read Pending admin review bug [core label] triage Maintainer needs to classify the issue labels Dec 29, 2024
@dmvianna
Copy link

dmvianna commented Jan 10, 2025

To reproduce the behaviour seen in Emacs we would need four commands:

  • editor::KillRingYank: pastes the item at the head of the kill ring (in Emacs: yank;
  • editor::KillRingCut: cuts an item from the text and adds it to the head of the kill ring (in Emacs: kill-region);
  • editor::KillRingSave: copies an item from the text and adds it to the head of the kill ring (unimplemented in Zed, in Emacs: kill-ring-save);
  • editor::KillRingPop: if not preceded by a call to KillRingYank opens a modal showing the contents of the kill-ring; if preceded by KillRingYank it replaces the previously yanked item with the preceding item in the kill-ring (unimplemented in Zed, in Emacs: kill-ring-pop).

The kill ring has a configurable size. Once it reaches its limit, it goes back to the beginning. Hence, it is a ring.

@notpeter notpeter added editor Feedback for code editing, formatting, editor iterations, etc and removed triage Maintainer needs to classify the issue admin read Pending admin review labels Jan 10, 2025
@notpeter notpeter changed the title Editor::KillRingCut is not accumulating multiple lines? Editor::KillRingCut is not accumulating multiple lines? (emacs) Jan 10, 2025
@notpeter notpeter added enhancement [core label] and removed bug [core label] labels Jan 10, 2025
@notpeter notpeter changed the title Editor::KillRingCut is not accumulating multiple lines? (emacs) Editor::KillRingCut support for multiple lines? (emacs) Jan 10, 2025
@notpeter
Copy link
Member

The initial implementation of kill/yank was an initial stab at supporting the single line form of cut yank:

I'd like to keep this issue bite-sized and focused on extended cut/yank to support multiple successive editor::KillRingCut collecting multiple lines which can be then be yanked together with editor::KillRingYank. This would match the behavior of macOS native controls with ctrl-k / ctrl-y.

Support for proper kill-ring which preserves previously killed items and allows selecting from them would require some design work -- kill-ring-pop in Zed would likely be implemented as navigable modal which would also allow you to delete items (equivalent to delete-from-kill-ring in emacs) at the same time. Zed does similar things in vim-mode, but so-far all the emacs functionality has been implemented purely as keybinds and generic actions without requiring an additional emacs-mode and the code / complexity to support that.

While not supported in macOS controls, readline does support kill-ring-save (M-w). Perhaps that could be similarly implemented without requiring full blown kill-ring.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
editor Feedback for code editing, formatting, editor iterations, etc enhancement [core label]
Projects
None yet
Development

No branches or pull requests

3 participants