wez / wezterm

A GPU-accelerated cross-platform terminal emulator and multiplexer written by @wez and implemented in Rust
https://wezfurlong.org/wezterm/
Other
14.94k stars 677 forks source link

Linebreaks introduced in long lines when selecting text #874

Closed dev-zero closed 2 years ago

dev-zero commented 3 years ago

Describe the bug

When copying very long lines I get artificial line breaks inserted at wrong places.

Environment (please complete the following information):

To Reproduce

Steps to reproduce the behavior.

I select some very long content and then yank it with the middle-mouse, or I copy it with ctrl+shift+c and then paste it with ctrl+shift+v somewhere else then I get additional line breaks in the pasted output.

Example:

gcc -march=znver2 -shared -fPIC -D__CRAY_X86_ROME -D__CRAYXT_COMPUTE_LINUX_TARGET -D__TARGET_LINUX__ -march=znver2 -mtune=znver2 -I/opt/cray/pe/libsci/21.04.1.1/GNU/9.1/x86_64/include -L/opt/cray/pe/mpich/8.1.4/ofi/gnu/9.1/lib -L/opt/cray/pe/libsci/21.04.1.1/GNU/9.1/x86_64/lib -L/opt/cray/pe/dsmml/0.1.4/dsmml//lib -L/opt/cray/xpmem/2.2.40-7.0.1.0_1.9__g1d7a24d.shasta/lib64 -L/opt/gcc/10.2.0/snos/lib/gcc/x86_64-suse-linux/10.2.0 -L/opt/gcc/10.2.0/snos/lib/gcc/x86_64-suse-linux/10.2.0/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/opt/gcc/10.2.0/snos/lib/gcc/x86_64-suse-linux/10.2.0/../../.. -L/opt/cray/pe/libsci/21.04.1.1/GNU/9.1/x86_64/lib -Wl,--disable-new-dtags -Wl,-rpath,/project/d110/timuel/spack/opt/spack/cray-sles15-zen2/gcc-10.2.0/amdlibflame-3.0-gvcr5zajxoq6blmvecoirkvtz7acnvno/lib -Wl,-rpath,/project/d110/timuel/spack/opt/spack/cray-sles15-zen2/gcc-10.2.0/amdlibflame-3.0-gvcr5zajxoq6blmvecoirkvtz7acnvno/lib64 -Wl,-rpath,/opt/cray/pe/libsci/21.04.1.1/GNU/9.1/x86_64/lib -Wl,-rpath,/opt/gcc/10.2.0/snos/lib/gcc/x86_64-suse-linux/10.2.0 -Wl,-rpath,/opt/gcc/10.2.0/snos/lib64 -o lib/x86_64-unknown-linux-gnu/libflame.so -Wl,-soname,libflame.so.3 -Wl,--whole-archive libflame.a -Wl,--no-whole-archive -lsci_gnu_mpi_mp -lsci_gnu_mp -lsci_gnu_82_mpi -lsci_gnu_82 -ldl -lmpifort_gnu_91 -lmpi_gnu_91 -lxpmem -ldsmml -lgfortran -lquadmath -lpthread -lm -fopenmp -I/opt/cray/pe/mpich/8.1.4/ofi/gnu/9.1/include -I/opt/cray/pe/libsci/21.04.1.1/GNU/9.1/x86_64/include -I/opt/cray/pe/dsmml/0.1.4/dsmml//include -I/opt/cray/xpmem/2.2.40-7.0.1.0_1.9__g1d7a24d.shasta/include -L/opt/cray/pe/mpich/8.1.4/ofi/gnu/9.1/lib -L/opt/cray/pe/libsci/21.04.1.1/GNU/9.1/x86_64/lib -L/opt/cray/pe/dsmml/0.1.4/dsmml//lib -L/opt/cray/xpmem/2.2.40-7.0.1.0_1.9__g1d7a24d.shasta/lib64 -Wl,--as-needed,-lsci_gnu_82_mpi_mp,--no-as-needed -Wl,--as-needed,-lsci_gnu_82_mp,--no-as-needed -ldl -Wl,--as-needed,-lmpi_gnu_91,--no-as-needed -lxpmem -Wl,--as-needed,-ldsmml,--no-as-needed -Wl,--as-needed,-lgfortran,-lquadmath,--no-as-needed -Wl,--as-needed,-lmvec,--no-as-needed -Wl,--as-needed,-lm,--no-as-needed -Wl,--as-needed,-lpthread,--no-as-needed

becomes after the paste:

gcc -march=znver2 -shared -fPIC -D__CRAY_X86_ROME -D__CRAYXT_COMPUTE_LINUX_TARGET -D__TARGET_LINUX__ -march=znver2 -mtune=znver2 -I/opt/cray/pe/libsci/21.04.1.1/GNU/9.1/x86_64/include -L/opt/cray/pe/mpich/8.1.4/ofi/gnu/9.1/lib -L/opt/cray/pe/libsci/21.04.1.1/GNU/9.1/x86_64/lib -L/opt/cray/pe/dsmml/0.1.4/dsmml//lib -L/opt/cray/xpmem/2.2.40-7.0.1.0_1.9__g1d7a24d.shasta/lib64 -L/opt/gcc/10.2.0/snos/lib/gcc/x86_64-suse-linux/10.2.0 -L/opt/gcc/10.2.0/snos/lib/gcc/x86_64-suse-linux/10.2.0/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/opt/gcc/10.2.0/snos/lib/gcc/x86_64-suse-linux/10.2.0/../../.. -L/opt/cray/pe/libsci/21.04.1.1/GNU/9.1/x86_64/lib -Wl,--disable-new-dtags -Wl,-rpath,/project/d110/timuel/spack/opt/spack/cray-sles15-zen2/gcc-10.2.0/amdlibflame-3.0-gvcr5zajxoq6blmvecoirkvtz7acnvno/lib -Wl,-rpath,/project/d110/timuel/spack/opt/spack/cray-sles15-zen2/gcc-10.2.0/amdlibflame-3.0-gvcr5zajxoq6blmvecoirkvtz7acnvno/lib64 -Wl,-rpath,/opt/cray/pe/libsci/21.04.1.1/GNU/9.1/x86_64/lib -Wl,-rpath,/opt/gcc/10.2.0/snos/lib/gcc/x86_64-suse-linux/10.2.0 -Wl,-rpath,/opt/gcc/10.2.0/snos/lib64 -o lib/x86_64-unknown-linux-gnu/libflame.so -Wl,-soname,libflame.so.3
-Wl,--whole-archive
libflame.a -Wl,--no-whole-archive -lsci_gnu_mpi_mp -lsci_gnu_mp -lsci_gnu_82_mpi -lsci_gnu_82 -ldl -lmpifort_gnu_91 -lmpi_gnu_91 -lxpmem -ldsmml -lgfortran -lquadmath -lpthread -lm -fopenmp -I/opt/cray/pe/mpich/8.1.4/ofi/gnu/9.1/include -I/opt/cray/pe/libsci/21.04.1.1/GNU/9.1/x86_64/include -I/opt/cray/pe/dsmml/0.1.4/dsmml//include -I/opt/cray/xpmem/2.2.40-7.0.1.0_1.9__g1d7a24d.shasta/include -L/opt/cray/pe/mpich/8.1.4/ofi/gnu/9.1/lib -L/opt/cray/pe/libsci/21.04.1.1/GNU/9.1/x86_64/lib -L/opt/cray/pe/dsmml/0.1.4/dsmml//lib -L/opt/cray/xpmem/2.2.40-7.0.1.0_1.9__g1d7a24d.shasta/lib64 -Wl,--as-needed,-lsci_gnu_82_mpi_mp,--no-as-needed -Wl,--as-needed,-lsci_gnu_82_mp,--no-as-needed -ldl -Wl,--as-needed,-lmpi_gnu_91,--no-as-needed -lxpmem -Wl,--as-needed,-ldsmml,--no-as-needed -Wl,--as-needed,-lgfortran,-lquadmath,--no-as-needed -Wl,--as-needed,-lmvec,--no-as-needed -Wl,--as-needed,-lm,--no-as-needed -Wl,--as-needed,-lpthread,--no-as-needed

Resizing the window does a correct reflow and shows that there's no linebreak in the original output (depending on the window width the linebreak changes position)

Configuration

local wezterm = require 'wezterm';
return {
  font = wezterm.font("Hack Nerd Font"),
  font_size = 10,
  color_scheme = "OneHalfDark",
  keys = {
    {key="DownArrow", mods="SHIFT", action=wezterm.action{SpawnTab="CurrentPaneDomain"}},
    {key="LeftArrow", mods="SHIFT", action=wezterm.action{ActivateTabRelative=-1}},
    {key="RightArrow", mods="SHIFT", action=wezterm.action{ActivateTabRelative=1}},
    {key="LeftArrow", mods="SHIFT|CTRL", action=wezterm.action{MoveTabRelative=-1}},
    {key="RightArrow", mods="SHIFT|CTRL", action=wezterm.action{MoveTabRelative=1}},
  }
}

Expected behavior

No line breaks.

wez commented 2 years ago

I've pushed a commit that seems to make this better; it will show up in the nightly downloads in ~30 minutes from now. Please give it a try and let me know how you get on!

dev-zero commented 2 years ago

@wez will do, thanks a lot!

dev-zero commented 2 years ago

ok, I've tested it with 40cb141a and it looks good now. What still puzzles me but is probably a different bug, is the selection on triple click: double click on text usually selects a word (depends on the emulator what it considers a word), but a triple click usually selects the complete line while wezterm selects only a part of the line (probably until a given max of chars?). See:

selection

wez commented 2 years ago

Yeah, this is expected behavior: triple click considers logical lines, but in order to constrain the cost of things like hyperlink rules that operate on logical lines, there is a maximum limit for logical line length. I know this isn't ideal.

As a potential alternative, I wanted to share that I use the configuration snippet shown here: https://wezfurlong.org/wezterm/config/lua/keyassignment/SelectTextAtMouseCursor.html

together with shell integration also linked in those docs, so that triple click gets me the entire section of text from the input/output semantic zone.

I'm going to close this as the original issue is resolved!

github-actions[bot] commented 1 year ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.