bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#31662: [PATCH] fix double counting bug in term.el


From: John Shahid
Subject: bug#31662: [PATCH] fix double counting bug in term.el
Date: Fri, 01 Jun 2018 02:51:11 +0000
User-agent: mu4e 1.1.0; emacs 27.0.50

Thanks for the feedback. I fixed both issues in the attached patch.

Noam Postavsky <address@hidden> writes:

> John Shahid <address@hidden> writes:
>>                    (when (not (or (eobp) term-insert-mode))
>>                      (let ((pos (point)))
>>                        (term-move-columns columns)
>> -                      (delete-region pos (point))))
>> +                      (delete-region pos (point))
>> +                      (term-move-columns (- columns))))
>
> I think it's a better idea to just reset term-current-column to nil,
> like what happens in Emacs 26.
>
>> +  (should (equal "abcde    j"
>> +                 (term-test-screen-from-input
>> +                  10 12 (concat "\e[mabcdefghij"
>> +                                "\e[H"  ;move back to point-min
>> +                                "\e[mabcde"
>> +                                "\e[m    j"))))
>> +
>
> The "\e[m" is just to make the strings get processed separately, right?
> You can pass a list of strings instead:
>
>     (term-test-screen-from-input
>      10 12 (list "abcdefghij"
>                  "\e[H" ;move back to point-min
>                  "abcde"
>                  "    j"))



>From c9a8ac75923f7b48bcf3285f2c3b6e3a6d9e75b2 Mon Sep 17 00:00:00 2001
From: John Shahid <address@hidden>
Date: Wed, 30 May 2018 23:55:16 -0400
Subject: [PATCH] * lisp/term.el (term-emulate-terminal): fix column double
 counting

---
 lisp/term.el            | 3 ++-
 test/lisp/term-tests.el | 7 +++++++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/lisp/term.el b/lisp/term.el
index 19e68ddb49..715f39bbbf 100644
--- a/lisp/term.el
+++ b/lisp/term.el
@@ -2904,7 +2904,8 @@ term-emulate-terminal
                   (when (not (or (eobp) term-insert-mode))
                     (let ((pos (point)))
                       (term-move-columns columns)
-                      (delete-region pos (point))))
+                      (delete-region pos (point))
+                      (setq term-current-column nil)))
                   ;; In insert mode if the current line
                   ;; has become too long it needs to be
                   ;; chopped off.
diff --git a/test/lisp/term-tests.el b/test/lisp/term-tests.el
index 8aaa61a210..72a9ad1ef7 100644
--- a/test/lisp/term-tests.el
+++ b/test/lisp/term-tests.el
@@ -89,6 +89,13 @@ term-test-screen-from-input
                                               "\e[2;1Hc"
                                               "\e[1;2Hb"
                                               "\e[1;1Ha") "" t))))
+  (should (equal "abcde    j"
+                 (term-test-screen-from-input
+                  10 12 '("abcdefghij"
+                          "\e[H"  ;move back to point-min
+                          "abcde"
+                          "    j"))))
+
   ;; Relative positioning.
   (should (equal "ab\ncd"
                  (term-test-screen-from-input
-- 
2.17.1


reply via email to

[Prev in Thread] Current Thread [Next in Thread]