Skip to content

Commit

Permalink
Clearing buffer for web worker REPL on error
Browse files Browse the repository at this point in the history
Fixes #318
  • Loading branch information
HenryS1 authored and davazp committed May 8, 2018
1 parent 2c9667e commit 07fa4f3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/read.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -547,10 +547,14 @@
(skip-whitespaces-and-comments stream)
(let ((ch (%peek-char stream)))
(cond
((or (null ch) (char= ch #\)))
((null ch)
(if eof-error-p
(error "End of file")
eof-value))
((char= ch #\))
(if eof-error-p
(error "unmatched close parenthesis")
eof-value))
((char= ch #\()
(%read-char stream)
(%read-list stream eof-error-p eof-value))
Expand Down
5 changes: 5 additions & 0 deletions src/worker.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,14 @@
(print result)))
(error (err)
(let ((*web-worker-output-class* "jqconsole-error"))
(clear-buffer)
(format t "ERROR: ")
(apply #'format t (!condition-args err))
(terpri)))))
(catch (err)
(let (((*web-worker-output-class* "jqconsole-error"))
(message (or (oget err "message") err)))
(clear-buffer)
(format t "ERROR[!]: ~a~%" message))))))


Expand Down Expand Up @@ -88,6 +90,9 @@
(setf *stdin-buffer* (concat *stdin-buffer* input))
*stdin-buffer*))

(defun clear-buffer ()
(setf *stdin-buffer* ""))

(defun %peek-char-stdin (&rest args)
(if (< 0 (length *stdin-buffer*))
(char *stdin-buffer* 0)
Expand Down

0 comments on commit 07fa4f3

Please sign in to comment.