I am using zellij as a terminal multiplexer/session manager (e.g. like tmux), below I will provide info related to zellij but please hear me out before closing this issue because I think the bug lies within hx itself and not zellij and I will explain why.
Zellij contains an "edit scrollback buffer" feature whereby one can press <Ctrl-s> and it dumps the current scrollback buffer to a temporary file before spawning whatever program you've configured as your scrollback editor (defaults to $EDITOR or $VISUAL contents).
I have found that when I use hx as my scrollback buffer editor the contents of the clipboard are lost as described in the bug reproduction steps.
However, when I configure nvim as my scrollback buffer editor the copy/paste behaviour works perfectly fine and clipboard contents are not lost.
I have done some investigation and I believe the problem, which only occurs when using hx as the scrollback editor, is likely due to differences in how xclip is spawned.
Specific differences in how xclip is spawned:
hx does not call setsid before spawning and calls xclip with the args xclip -i -selection clipboard
nvim calls setsid before spawning and calls xclip with the args xclip -quiet -i -selection clipboard
This is a dump of relevant htop output when using nvim to do a copy/paste within scrollback editing:
Note that the session ID and process group ID of xclip is different to that of nvim, I believe that is because nvim calls setsid before exec'ing xclip.
Now here is a dump of relevant htop output when using hx to do a copy/paste:
Note that the session ID and process group ID of xclip is the same as that of the spawned hx.
My suspicion is that when hx is closed the spawned xclip process is also closed because they are both in the same session / process group. Pasting then fails because xclip has been closed and X11 no longer has a source from which to get the clipboard contents.
Reasons I believe the bug is within hx and not zellij:
The same bug does not occur if I configure nvim as my scrollback editor
I have tried manually patching hx to call fork then setsid before launching xclip for copying and confirmed this fixes the bug.
Edit the config file, e.g. ~/.config/zellij/config.kdl
Change the value of scrollback_editor to the location of hx, e.g. "/usr/local/bin/hx"
To reproduce the bug itself:
Open new terminal
Enter zellij to start a new session running version 0.34.4 of zellij
Type ls -l to produce some terminal output
Press <Ctrl-s> to trigger scrollback edit mode (this dumps terminal contents to a file and opens hx for editing it).
Use hx to select some text then press <Space>y to yank to clipboard
Enter :q! to quit hx
Attempt to paste the yanked text back into the terminal or any other app
I expected this to happen:
The yanked text would be pasted
Instead, this happened:
Nothing is pasted
Additional info
It is only at step 8 (where hx is closed) that the clipboard contents are lost.
If the above steps are taken but step 8 is skipped, the copy/paste process works correctly. This is not ideal because the workflow I want to use is to use scrollback editing to quickly copy a subset of the terminal output text.
Summary
I am using zellij as a terminal multiplexer/session manager (e.g. like
tmux
), below I will provide info related to zellij but please hear me out before closing this issue because I think the bug lies withinhx
itself and notzellij
and I will explain why.Zellij
contains an "edit scrollback buffer" feature whereby one can press<Ctrl-s>
and it dumps the current scrollback buffer to a temporary file before spawning whatever program you've configured as your scrollback editor (defaults to $EDITOR or $VISUAL contents).I have found that when I use
hx
as my scrollback buffer editor the contents of the clipboard are lost as described in the bug reproduction steps.However, when I configure
nvim
as my scrollback buffer editor the copy/paste behaviour works perfectly fine and clipboard contents are not lost.I have done some investigation and I believe the problem, which only occurs when using
hx
as the scrollback editor, is likely due to differences in howxclip
is spawned.Specific differences in how
xclip
is spawned:hx
does not callsetsid
before spawning and calls xclip with the argsxclip -i -selection clipboard
nvim
callssetsid
before spawning and calls xclip with the argsxclip -quiet -i -selection clipboard
This is a dump of relevant
htop
output when usingnvim
to do a copy/paste within scrollback editing:Note that the session ID and process group ID of
xclip
is different to that ofnvim
, I believe that is because nvim callssetsid
before exec'ingxclip
.Now here is a dump of relevant
htop
output when usinghx
to do a copy/paste:Note that the session ID and process group ID of
xclip
is the same as that of the spawnedhx
.My suspicion is that when
hx
is closed the spawnedxclip
process is also closed because they are both in the same session / process group. Pasting then fails becausexclip
has been closed and X11 no longer has a source from which to get the clipboard contents.Reasons I believe the bug is within
hx
and notzellij
:nvim
as my scrollback editorhx
to callfork
thensetsid
before launchingxclip
for copying and confirmed this fixes the bug.Reproduction Steps
Environment setup:
~/.config/zellij/config.kdl
scrollback_editor
to the location ofhx
, e.g."/usr/local/bin/hx"
To reproduce the bug itself:
zellij
to start a new session running version 0.34.4 of zellijls -l
to produce some terminal output<Ctrl-s>
to trigger scrollback edit mode (this dumps terminal contents to a file and openshx
for editing it).hx
to select some text then press<Space>y
to yank to clipboard:q!
to quithx
I expected this to happen:
The yanked text would be pasted
Instead, this happened:
Nothing is pasted
Additional info
It is only at step 8 (where
hx
is closed) that the clipboard contents are lost. If the above steps are taken but step 8 is skipped, the copy/paste process works correctly. This is not ideal because the workflow I want to use is to use scrollback editing to quickly copy a subset of the terminal output text.Helix log
No response
Platform
Linux (X11 running BSPWM)
Terminal Emulator
Alacritty 0.11.0
Helix Version
helix 22.12 (96ff64a8)