Subject: Bad interaction between visual-line-mode and wrap-prefix on long lines

From: Clément Pit-Claudel <[email-masked]>
Date: Thu, 31 May 2018 08:27:43 -0400

Hi all,

I use adaptive-wrap-prefix-mode from ELPA to get nice looking line-wrapping, and I also usually have visual-line-mode enabled.  Using the two together causes a rendering issue for long lines with no spaces in them: they are displayed with a preceding blank line added.

The following snippet demonstrates the problem:

(with-current-buffer (get-buffer-create "wrap")
  (text-mode)
  (visual-line-mode)
  (erase-buffer)
  (let* ((prefix (make-string 16 ?\s))
         (aaa (make-string 260 ?A)))
    (insert prefix (propertize aaa 'wrap-prefix prefix) "\n")
    (insert (propertize (concat prefix aaa) 'wrap-prefix prefix) "\n"))
  (display-buffer (current-buffer)))

Here's what the output looks like:

-----------
               
                AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
                AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
                AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
                AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
                AAAA
               
                AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
                AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
                AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
                AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
                AAAA
-----------

Notice how each line of AAA is preceded with a blank line (containing just 15 spaces).  I was expecting that code to produce this rendering instead (This is what you get if you turn off visual-line-mode):

-----------
                AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
                AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
                AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
                AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
                AAAA
                AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
                AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
                AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
                AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
                AAAA
-----------

Is this expected?

Thanks,
Clément.