Skip to content

Commit 3f8b190

Browse files
committed
Fix multibyte handling
Fixes #32
1 parent 12d020b commit 3f8b190

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

dap-mode.el

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -486,8 +486,9 @@ thread exection but the server will log message."
486486

487487
(defun dap--parser-read (p output)
488488
"Parser OUTPUT using parser P."
489-
(let ((messages '())
490-
(chunk (concat (dap--parser-leftovers p) output)))
489+
(let* ((messages '())
490+
(output (string-as-unibyte output))
491+
(chunk (concat (dap--parser-leftovers p) output)))
491492
(while (not (string-empty-p chunk))
492493
(if (not (dap--parser-reading-body p))
493494
;; Read headers

tests/dap-test.el

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,16 @@
4747
'("{\"somedata\":2}")))))
4848

4949
(ert-deftest dap--parser-read--multiple-multibyte-chunks ()
50-
(let* ((p (make-dap--parser)))
50+
(let ((p (make-dap--parser)))
5151
(should (equal (dap--parser-read p "Content-Length: 18\r") nil))
5252
(should (equal (dap--parser-read p "\n\r\n{\"somedata\":\"\xe2\x80") nil))
5353
(should (equal (dap--parser-read p "\x99\"}Content-Length: 14\r\n\r\n{")
5454
'("{\"somedata\":\"\"}")))
5555
(should (equal (dap--parser-read p "\"somedata\":2}")
56-
'("{\"somedata\":2}")))))
56+
'("{\"somedata\":2}"))))
57+
(let ((p (make-dap--parser)))
58+
(should (equal (dap--parser-read p "Content-Length: 238\r\n\r\n{\"event\":\"output\",\"body\":{\"category\":\"stdout\",\"output\":\"2019-01-13 00:16:36 [ main ] - [ INFO com.inspur.common.utils.PropertiesBuilder.getConfig(32)] 从jar内加载:kafka-producer.properties\\n\",\"type\":\"output\"},\"seq\":9,\"type\":\"event\"}") '("{\"event\":\"output\",\"body\":{\"category\":\"stdout\",\"output\":\"2019-01-13 00:16:36 [ main ] - [ INFO com.inspur.common.utils.PropertiesBuilder.getConfig(32)] 从jar内加载:kafka-producer.properties\\n\",\"type\":\"output\"},\"seq\":9,\"type\":\"event\"}")))))
59+
5760

5861
(provide 'dap-test)
5962
;;; dap-test.el ends here

0 commit comments

Comments
 (0)