]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix vertical cursor motion with wide images and line numbers
authorEli Zaretskii <eliz@gnu.org>
Wed, 26 Mar 2025 17:04:16 +0000 (19:04 +0200)
committerEshel Yaron <me@eshelyaron.com>
Thu, 27 Mar 2025 10:12:46 +0000 (11:12 +0100)
* src/xdisp.c (produce_image_glyph): When cropping an image that
exceeds the window's right edge, account for the screen estate
taken by line-number display.  (Bug#77217)

(cherry picked from commit 1e68351d56918cd4d7883bcff629f794660a3134)

src/xdisp.c

index 5845f941a8fb95196d75fc1b2b677f7ff1f3772b..fd997f443eacefb70c4b164d0a70393ace53753d 100644 (file)
@@ -31956,12 +31956,14 @@ produce_image_glyph (struct it *it)
      word-wrap, unless the image starts at column zero, because
      wrapping correctly needs the real pixel width of the image.  */
   if ((it->line_wrap != WORD_WRAP
-       || it->hpos == 0
+       || it->hpos == (0 + (it->lnum_width ? it->lnum_width + 2 : 0))
        /* Always crop images larger than the window-width, minus 1 space.  */
-       || it->pixel_width > it->last_visible_x - FRAME_COLUMN_WIDTH (it->f))
+       || it->pixel_width > (it->last_visible_x - it->lnum_pixel_width
+                            - FRAME_COLUMN_WIDTH (it->f)))
       && (crop = it->pixel_width - (it->last_visible_x - it->current_x),
          crop > 0)
-      && (it->hpos == 0 || it->pixel_width > it->last_visible_x / 4))
+      && (it->hpos == (0 + (it->lnum_width ? it->lnum_width + 2 : 0))
+         || it->pixel_width > it->last_visible_x / 4))
     {
       it->pixel_width -= crop;
       slice.width -= crop;