VSCodeVim / Vim

:star: Vim for Visual Studio Code
http://aka.ms/vscodevim
MIT License
13.89k stars 1.31k forks source link

"gq" is not working properly when it is supposed to join two lines #7056

Open XiaoCasd opened 3 years ago

XiaoCasd commented 3 years ago

Describe the bug Suppose I have two lines, each of them has fewer words than the "vim.textwidth". When my cursor is on the first line, if I press "gq+j", the two lines can not be joined, but rather whitespace will be placed before the second line.

To Reproduce

  1. Set vim.textwidth to some value (I use 35)
  2. Type two lines, e.g. image
  3. Put the cursor on the first line and then press "gq" then "j"
  4. Result: image

Expected behavior After pressing "gq+j" it should become image

Environment (please complete the following information):

Additional context This bug should be caused by update 1.20.2.

nnen commented 1 month ago

Same problem seems to affect {Visual}gq.

I found out the issue seems to be happening only in with end of line sequence set to CRLF. If I switch the end of line sequence to LF, the gq command behaves as expected. I'm guessing the gq command is not handling the \r\n sequence correctly.