1
0
mirror of https://github.com/janet-lang/janet synced 2024-11-25 09:47:17 +00:00

Fix flag check in pretty print.

This commit is contained in:
Calvin Rose 2020-04-28 10:00:24 -05:00
parent 70e1f3ac81
commit 63e9790123
2 changed files with 6 additions and 5 deletions

View File

@ -2505,7 +2505,6 @@
the repl in." the repl in."
[&opt chunks onsignal env] [&opt chunks onsignal env]
(default env (make-env)) (default env (make-env))
(defn repl-wrap [x] (pp x) x)
(default chunks (default chunks
(fn [buf p] (fn [buf p]
(getline (getline
@ -2541,14 +2540,16 @@
(fn [f x] (fn [f x]
(if (= :dead (fiber/status f)) (if (= :dead (fiber/status f))
(put e '_ @{:value x}) (do
(put e '_ @{:value x})
(printf (get e :pretty-format "%q") x)
(flush))
(if (e :debug) (if (e :debug)
(enter-debugger f x) (enter-debugger f x)
(do (debug/stacktrace f x) (eflush)))))) (do (debug/stacktrace f x) (eflush))))))
(run-context {:env env (run-context {:env env
:chunks chunks :chunks chunks
:expander (fn [x] [repl-wrap x])
:on-status (or onsignal (make-onsignal env 1)) :on-status (or onsignal (make-onsignal env 1))
:source "repl"})) :source "repl"}))

View File

@ -527,7 +527,7 @@ static void janet_pretty_one(struct pretty *S, Janet x, int is_dict_value) {
if (!isarray && !(S->flags & JANET_PRETTY_ONELINE) && len >= JANET_PRETTY_IND_ONELINE) if (!isarray && !(S->flags & JANET_PRETTY_ONELINE) && len >= JANET_PRETTY_IND_ONELINE)
janet_buffer_push_u8(S->buffer, ' '); janet_buffer_push_u8(S->buffer, ' ');
if (is_dict_value && len >= JANET_PRETTY_IND_ONELINE) print_newline(S, 0); if (is_dict_value && len >= JANET_PRETTY_IND_ONELINE) print_newline(S, 0);
if (len > JANET_PRETTY_ARRAY_LIMIT && !(S->flags && JANET_PRETTY_NOTRUNC)) { if (len > JANET_PRETTY_ARRAY_LIMIT && !(S->flags & JANET_PRETTY_NOTRUNC)) {
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++) {
if (i) print_newline(S, 0); if (i) print_newline(S, 0);
janet_pretty_one(S, arr[i], 0); janet_pretty_one(S, arr[i], 0);
@ -591,7 +591,7 @@ static void janet_pretty_one(struct pretty *S, Janet x, int is_dict_value) {
if (is_dict_value && len >= JANET_PRETTY_DICT_ONELINE) print_newline(S, 0); if (is_dict_value && len >= JANET_PRETTY_DICT_ONELINE) print_newline(S, 0);
for (i = 0; i < cap; i++) { for (i = 0; i < cap; i++) {
if (!janet_checktype(kvs[i].key, JANET_NIL)) { if (!janet_checktype(kvs[i].key, JANET_NIL)) {
if (counter == JANET_PRETTY_DICT_LIMIT && !(S->flags && JANET_PRETTY_NOTRUNC)) { if (counter == JANET_PRETTY_DICT_LIMIT && !(S->flags & JANET_PRETTY_NOTRUNC)) {
print_newline(S, 0); print_newline(S, 0);
janet_buffer_push_cstring(S->buffer, "..."); janet_buffer_push_cstring(S->buffer, "...");
break; break;