mobile-shell / mobile-shell/mosh

[Bug] Visual selection of a wrapped line in Vim shows incorrect characters

Open
#1,295 1 comment 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
14.5k
Forks
865
PR merge metrics
No merged PRs in 30d

Description

Steps to reproduce
  1. Create a file named mini.vim with the following contents (I tried both gruvbox and solarized and observed the same behavior):
set nocompatible
set runtimepath^=/home/user/.vim/plugged/gruvbox

colorscheme gruvbox
set background=dark

set number
  1. Open a tmux session by running tmux -Lx -f /dev/null.

  2. Open a file with wrapped lines while using the above Vim preferences, e.g., vim -u mini.vim README.md (the screenshots below show a row of a table written in markdown).

  3. See how visual selection of a wrapped line with V moves some characters to the number column and eliminates some other characters. The line wraps at the word "screen" where "s" is at the end of the top line on the screen and "creen" is at the beginning of the bottom line on the screen. After selecting the line with V the following occur:

  • The letter "s" is dropped and the letter "c" in "screen" becomes the last character in the top line.
  • The bottom line is dedented and starts right below the number column where naturally, there should be no text.

Before visual selection:
Before

After visual selection:
After

Expected behaviour

The expected behavior is for the characters to remain in their original position.

Version of mosh

Built from the source (https://github.com/mobile-shell/mosh/commit/1105d481bb9143dad43adf768f58da7b029fd39c)

Version of Vim

9.0.1435 (tested with the latest version (1901) as well)

Version of tmux

3.2a (tested with the latest version (3.3a) as well)

Environment

Operating system: Ubuntu 22.04 accessed through mosh via macOS Ventura 13.5.2
Terminal: iTerm 2
Value of $TERM: screen-256color
Shell: zsh

This issue only occurs when using mosh and inside a tmux session. Using SSH, opening Vim outside a tmux session, or local Vim/tmux do not exhibit the same behavior.

(Possibly) Related Bugs

Screen corruption with neovim (#1041)

This bug was originally reported on Vim's GitHub repository (#13101), but after a few discussions and comparison with SSH, the mosh/tmux combination seems to be the culprit.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with the supplied mini.vim configuration, Vim, mosh, tmux, and screen-256color, then compare behavior with SSH and outside tmux as described. Use the Vim and mosh issue references to narrow the terminal-rendering path; done means visual selection leaves wrapped characters in their original positions.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, vim
Domain
cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.