unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#31662: [PATCH] fix double counting bug in term.el
@ 2018-05-31  4:49 John Shahid
  2018-05-31 22:51 ` Noam Postavsky
  0 siblings, 1 reply; 6+ messages in thread
From: John Shahid @ 2018-05-31  4:49 UTC (permalink / raw)
  To: 31662

[-- Attachment #1: Type: text/plain, Size: 418 bytes --]


Hi all,

Today I was trying to run fzf[1] in term when I ran into a weird issue
that will cause the term output to be clobbered with certain output. The
root cause seems to be a double counting in the column offset. This is
usually fine, unless `2*len(inserted text)' causes the point to be equal
to the window width. I fixed the issue and added a new test in the
attached patch

[1] https://github.com/junegunn/fzf


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-lisp-term.el-term-emulate-terminal-fix-column-double.patch --]
[-- Type: text/x-diff, Size: 1773 bytes --]

From efeec7bb556084f7004a83faf679f724bb8a0fe8 Mon Sep 17 00:00:00 2001
From: John Shahid <jvshahid@gmail.com>
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..67cebda1be 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))
+                      (term-move-columns (- columns))))
                   ;; 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..e27dd0354d 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 (concat "\e[mabcdefghij"
+                                "\e[H"  ;move back to point-min
+                                "\e[mabcde"
+                                "\e[m    j"))))
+
   ;; Relative positioning.
   (should (equal "ab\ncd"
                  (term-test-screen-from-input
-- 
2.17.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-06-02  3:13 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-05-31  4:49 bug#31662: [PATCH] fix double counting bug in term.el John Shahid
2018-05-31 22:51 ` Noam Postavsky
2018-06-01  2:51   ` John Shahid
2018-06-02  2:24     ` Noam Postavsky
2018-06-02  2:43       ` John Shahid
2018-06-02  3:13         ` Noam Postavsky

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).