Skip to content

Commit 0daff60

Browse files
dalgongtaku0
authored andcommitted
Fix unreadable characters appearing in repl prompt
This seems a better fix for #132; The original solution didn't work for me.
1 parent d266fbd commit 0daff60

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

swift-mode-repl.el

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -176,21 +176,25 @@ Runs the hook `swift-repl-mode-hook' \(after the `comint-mode-hook' is run).
176176
(cmd-string (swift-mode:command-list-to-string cmd))
177177
(cmd-list (swift-mode:command-string-to-list cmd))
178178
(buffer-name (concat "*Swift REPL [" cmd-string "]*"))
179-
(buffer (get-buffer-create buffer-name)))
180-
(unless dont-switch
181-
(pop-to-buffer buffer))
182-
(with-current-buffer buffer
183-
(unless (comint-check-proc buffer-name)
184-
(save-excursion
185-
(apply 'make-comint-in-buffer
186-
cmd-string buffer (car cmd-list) nil (cdr cmd-list))
187-
(swift-repl-mode)))
188-
(setq-local swift-mode:repl-buffer buffer-name))
179+
(buffer (get-buffer-create buffer-name))
180+
old-size)
189181
(with-current-buffer original-buffer
190-
(setq-local swift-mode:repl-buffer buffer-name)
182+
(setq-local swift-mode:repl-buffer buffer)
191183
(unless keep-default
192184
(setq-local swift-mode:repl-executable cmd)
193-
(setq-default swift-mode:repl-buffer swift-mode:repl-buffer)))))
185+
(setq-default swift-mode:repl-buffer swift-mode:repl-buffer)))
186+
(with-current-buffer buffer
187+
(setq old-size (buffer-size))
188+
(swift-repl-mode)
189+
(setq-local swift-mode:repl-buffer buffer))
190+
(unless (comint-check-proc buffer)
191+
(apply 'make-comint-in-buffer
192+
cmd-string buffer (car cmd-list) nil (cdr cmd-list))
193+
(with-current-buffer buffer
194+
(while (= old-size (buffer-size))
195+
(sleep-for .1))))
196+
(unless dont-switch
197+
(pop-to-buffer buffer))))
194198

195199
;;;###autoload
196200
(defalias 'run-swift 'swift-mode:run-repl)

0 commit comments

Comments
 (0)