syl20bnr / spacemacs

A community-driven Emacs distribution - The best editor is neither Emacs nor Vim, it's Emacs *and* Vim!
http://spacemacs.org
GNU General Public License v3.0
23.64k stars 4.89k forks source link

helm-show-kill-ring does not replace current selection #12328

Closed MarcoIeni closed 2 years ago

MarcoIeni commented 5 years ago

Description :octocat:

helm-show-kill-ring does not replace current selection

Reproduction guide :beetle:

Observed behaviour: :eyes: :broken_heart: selected text is not replaced, but the entry from the kill ring is simply pasted after the cursor

Expected behaviour: :heart: :smile: selected text is replaced with the entry from the kill ring

System Info :computer:

duianto commented 5 years ago

This seems to be unrelated to Spacemacs, because it happens with:

MarcoIeni commented 5 years ago

If delete-selection-mode is enabled then it works as expected. Do you think it is a good idea to create a spacemacs function that enables this mode before calling helm-show-kill-ring and before exiting the function disables the mode again if it was not enabled at the beginning?

duianto commented 5 years ago

There seems to be an issue when the selection end is at the end of a line.

With this example:

    (defun spacemacs/helm-show-kill-ring ()
      (interactive)
      (let ((delete-selection-mode t))
        (helm-show-kill-ring)))

    (spacemacs||set-helm-key "ry" spacemacs/helm-show-kill-ring)

After evaluating the code above. Type: abc Delete it to the kill-ring: diw Type: 123 Select the 3 with v After inserting from the helm kill-ring SPC r y with RET it ends up with: 1abc2

The cursor seems to move back one character before inserting the kill-ring item.

Because with 23 selected it ends up with abc1.

System Info :computer:

MarcoIeni commented 5 years ago

Yes, I was able to reproduce your behavior. Of course this also happens if you don't evaluate yuor function and you just use helm-show-kill-ring with delete-selection-mode enabled.

I think we should open an issue on https://github.com/emacs-helm/helm.

MarcoIeni commented 5 years ago

I also noticed that the selection is not replaced also if from the menu bar you go to Edit -> Paste from Kill menu. While if you use Edit -> Paste the text is replaced. This is not helm related I think.

Edit: I just tried this with emacs -Q and the behavior is the same, so it is just how emacs works I guess :/

duianto commented 5 years ago

It might just be an issue in Spacemacs, because it works as expected when starting emacs -q with evil and helm loaded.

Correction

The issue also occurs without Spacemacs when helm-show-kill-ring is called from a key binding, but it works when it's called from M-x.

When delete-selection-mode is enabled.

Then both of the following commands work: 12abc

But calling them from a key binding doesn't work: 1abc2

(global-set-key (kbd "<f8>") 'helm-show-kill-ring)
(global-set-key (kbd "<f9>") 'spacemacs/helm-show-kill-ring)

When delete-selection-mode is disabled.

M-x helm-show-kill-ring and f8 behaves as expected: 123abc and just inserts the kill-ring item after the cursor.

M-x spacemacs/helm-show-kill-ring works 12abc but f9 doesn't work: 1abc2

In Spacemacs, None of the scenarios above work.

github-actions[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Please let us know if this issue is still valid!

MarcoIeni commented 4 years ago

I did some testing and there are still issues with helm-show-kill-ring

lebensterben commented 3 years ago

I just tested on latest develop branch. And I'm not able to reproduce the bug.

First, start a new buffer, for example a scratch buff with SPC b s. Then, insert some text, e.g.

foo
bar
baz

I deleted the third line with dd, then it looks like

foo
bar

With delete-selection-mode enabled. Selecting the first line, i.e. foo, and then press SPC r y to run lazy-helm/helm-show-kill-ring and select the entry containing baz, it works as expected. ( it added a trailing new line because dd implicitly deleted a newline)

baz

bar
lebensterben commented 3 years ago

@MarcoIeni Please verify whether this is still an issue.

MarcoIeni commented 3 years ago

I was able to reproduce this with delete-selection-mode disabled.

I was also able to reproduce this.

lebensterben commented 3 years ago

@MarcoIeni I know that you were able to reproduce it before. But the question is are you still able to reproduce it now.

MarcoIeni commented 3 years ago

Yes, sorry, that's what I meant. I just reproduced the issues yesterday again.

lebensterben commented 3 years ago

@MarcoIeni Can you repeat what I did here https://github.com/syl20bnr/spacemacs/issues/12328#issuecomment-920360214

And let me know from which step things doesn't work properly.

MarcoIeni commented 3 years ago

What you did works for me. But the comments I linked are still valid.

lebensterben commented 3 years ago

I was able to reproduce this with delete-selection-mode disabled.

This is not a bug.

I was also able to reproduce this.

This one is and I can reproduce it. But this seems to be an upstream bug. I tried with helm-show-kill-ring and the issue persists.

MarcoIeni commented 3 years ago

Ok, we can close this if you want. Or we can keep it opened to track when the upstream issue will be solved.