aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJohn Shahid2019-04-29 13:53:38 -0400
committerStefan Monnier2019-05-07 14:51:42 -0400
commite44b56d16ad0749e599700a73509c16391ed973e (patch)
tree30fa77764767cdd4a954d94383c703db0f1dac9d /test
parent32cf07819ae8cfdbf14e00f351c7f520fff325c3 (diff)
downloademacs-e44b56d16ad0749e599700a73509c16391ed973e.tar.gz
emacs-e44b56d16ad0749e599700a73509c16391ed973e.zip
Fix setting and resetting of scroll-with-delete
The start and end lines of the scroll region must to be in the range [0,term-height). There are few placees that incorrectly set the end line of the scroll region to term-height which is outside the valid range. Combined with another off-by-one error in term-set-scroll-region's clamping logic, this would cause term-scroll-with-delete to be unnecessarily turned on. * lisp/term.el (term-scroll-start,term-scroll-end): Use defvar-local to define the variables and document the valid range of values that the variables can take. (term--last-line): New function to calculate the 0-based index of the last line. (term--reset-scroll-region): New function to reset the scroll region to the full height of the terminal. (term-mode,term-reset-size,term-reset-terminal): Call term--reset-scroll-region to reset the scroll region. (term-set-scroll-region): Fix the off-by-one error in the clamping logic which allowed term-scroll-end to have values outside the valid range [0,term-height).
Diffstat (limited to 'test')
-rw-r--r--test/lisp/term-tests.el136
1 files changed, 135 insertions, 1 deletions
diff --git a/test/lisp/term-tests.el b/test/lisp/term-tests.el
index 9f5dcd559eb..6923096d224 100644
--- a/test/lisp/term-tests.el
+++ b/test/lisp/term-tests.el
@@ -119,7 +119,141 @@ line3\r
119line4\r 119line4\r
120line5\r 120line5\r
121line6\r 121line6\r
122")))) 122")))
123
124 ;; test reverse scrolling
125 (should (equal "line1
126line7
127line6
128line2
129line5"
130 (term-test-screen-from-input 40 5
131 '("\e[0;0H"
132 "\e[J"
133 "line1\r
134line2\r
135line3\r
136line4\r
137line5"
138 "\e[2;4r"
139 "\e[2;0H"
140 "\e[2;0H"
141 "\eMline6"
142 "\e[2;0H"
143 "\eMline7"))))
144
145 ;; test scrolling down
146 (should (equal "line1
147line3
148line4
149line7
150line5"
151 (term-test-screen-from-input 40 5
152 '("\e[0;0H"
153 "\e[J"
154 "line1\r
155line2\r
156line3\r
157line4\r
158line5"
159 "\e[2;4r"
160 "\e[2;0H"
161 "\e[4;5H"
162 "\n\rline7"))))
163
164 ;; setting the scroll region end beyond the max height should not
165 ;; turn on term-scroll-with-delete
166 (should (equal "line1
167line2
168line3
169line4
170line5
171line6
172line7"
173 (term-test-screen-from-input 40 5
174 '("\e[1;10r"
175 "line1\r
176line2\r
177line3\r
178line4\r
179line5\r
180line6\r
181line7"))))
182
183
184 ;; resetting the terminal should set the scroll region end to (1- term-height).
185 (should (equal "
186line1
187line2
188line3
189line4
190"
191 (term-test-screen-from-input 40 5
192 '("\e[1;10r"
193 "\ec" ;reset
194 "line1\r
195line2\r
196line3\r
197line4\r
198line5"
199 "\e[1;1H"
200 "\e[L"))))
201
202 ;; scroll region should be limited to the (1- term-height). Note,
203 ;; this fixes an off by one error when comparing the scroll region
204 ;; end with term-height.
205 (should (equal "
206line1
207line2
208line3
209line4
210"
211 (term-test-screen-from-input 40 5
212 '("\e[1;6r"
213 "line1\r
214line2\r
215line3\r
216line4\r
217line5"
218 "\e[1;1H" ;go back to home
219 "\e[L" ;insert a new line at the top
220 ))))
221
222 ;; setting the scroll region to the entire height should not turn on
223 ;; term-scroll-with-delete
224 (should (equal "line1
225line2
226line3
227line4
228line5
229line6"
230 (term-test-screen-from-input 40 5
231 '("\e[1;5r"
232 "line1\r
233line2\r
234line3\r
235line4\r
236line5\r
237line6"))))
238
239 ;; reset should reset term-scroll-with-delete
240 (should (equal "line1
241line2
242line3
243line4
244line5
245line6
246line7"
247 (term-test-screen-from-input 40 5
248 '("\e[2;5r" ;set the region
249 "\ec" ;reset
250 "line1\r
251line2\r
252line3\r
253line4\r
254line5\r
255line6\r
256line7")))))
123 257
124(ert-deftest term-set-directory () 258(ert-deftest term-set-directory ()
125 (let ((term-ansi-at-user (user-real-login-name))) 259 (let ((term-ansi-at-user (user-real-login-name)))