Skip to content

Commit 7829fac

Browse files
committed
Discard should apply to all output until control char
1 parent 6e274c8 commit 7829fac

File tree

2 files changed

+33
-6
lines changed

2 files changed

+33
-6
lines changed

js-comint-test.el

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,3 +213,30 @@ Array.valueOf
213213
"Array.propertyIsEnumerable"
214214
"Array.toLocaleString"
215215
"Array.valueOf"))))
216+
217+
(ert-deftest js-comint--completion-filter/test-discard ()
218+
"Output should be discarded."
219+
(with-temp-buffer
220+
(js-comint--reset-completion-state)
221+
(setq js-comint--discard-output 't)
222+
;; each should be empty
223+
(dolist (res (list (js-comint--completion-filter "foo")
224+
(js-comint--completion-filter "bar")
225+
(js-comint--completion-filter "")))
226+
(should (string-empty-p res)))
227+
;; then the the flag should be cleared
228+
(should-not js-comint--discard-output)))
229+
230+
(ert-deftest js-comint--completion-filter/test-discard-with-completion ()
231+
"Output should be discarded even when completion callback is set."
232+
(with-temp-buffer
233+
(js-comint--reset-completion-state)
234+
(setq js-comint--discard-output 't)
235+
(setq js-comint--post-completion-cb #'ignore)
236+
;; each should be empty
237+
(dolist (res (list (js-comint--completion-filter "foo")
238+
(js-comint--completion-filter "bar")
239+
(js-comint--completion-filter "")))
240+
(should (string-empty-p res)))
241+
;; the output should not be accumulated
242+
(should (string-empty-p js-comint--completion-output))))

js-comint.el

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -320,12 +320,12 @@ PREFIX is the original completion prefix string."
320320
(message "|%s|" output)
321321

322322
;; discard should work independently so that clear-repl-input can be used
323-
(when (and js-comint--discard-output
324-
(string-match-p "\\[[[:digit:]]+[AG]$" output))
325-
(when (functionp js-comint--discard-output)
326-
(funcall js-comint--discard-output output))
327-
(setq js-comint--discard-output nil
328-
output ""))
323+
(when js-comint--discard-output
324+
(when (string-match-p "\\[[[:digit:]]+[AG]$" output)
325+
(when (functionp js-comint--discard-output)
326+
(funcall js-comint--discard-output output))
327+
(setq js-comint--discard-output nil))
328+
(setq output ""))
329329

330330
(when js-comint--post-completion-cb
331331
(message "collecting output")

0 commit comments

Comments
 (0)