]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix vertical-motion when an image is at EOL under word-wrap
authorJD Smith <jdtsmith@gmail.com>
Wed, 4 Jun 2025 20:47:48 +0000 (16:47 -0400)
committerEshel Yaron <me@eshelyaron.com>
Sat, 7 Jun 2025 20:02:18 +0000 (22:02 +0200)
* src/xdisp.c (move_it_in_display_line_to): Fix return value under
word-wrap when a screen line ends with an image that "just fits".
(Bug#67604)

(cherry picked from commit 9b30934756ab4872134847ad98350637d690b988)

src/xdisp.c

index a55e0b41aea1442cca92dc6af505cd8eda42d670..519194f984af8a2f9323a95b554a040fab08122b 100644 (file)
@@ -10392,10 +10392,21 @@ move_it_in_display_line_to (struct it *it,
                              if (BUFFER_POS_REACHED_P ())
                                {
                                  if (ITERATOR_AT_END_OF_LINE_P (it))
-                                   result = MOVE_POS_MATCH_OR_ZV;
-                                 else
-                                   result = MOVE_LINE_CONTINUED;
-                                 break;
+                                   {
+                                     result = MOVE_POS_MATCH_OR_ZV;
+                                     break;
+                                   }
+                                 /* When word-wrapping IMAGES or
+                                    STRETCHES which just fit on a line,
+                                    do not return early, before the
+                                    wrap point can be restored */
+                                 else if ((prev_method != GET_FROM_STRETCH
+                                           && prev_method != GET_FROM_IMAGE)
+                                          || it->line_wrap != WORD_WRAP)
+                                   {
+                                     result = MOVE_LINE_CONTINUED;
+                                     break;
+                                   }
                                }
                              if (ITERATOR_AT_END_OF_LINE_P (it)
                                  && (it->line_wrap != WORD_WRAP