don't forget this case

v6.3-exception
Matthew Butterick 6 years ago
parent 1d2b75456e
commit 3003bc61c3

@ -8,6 +8,9 @@
(define (indent-jsonic tbox [posn 0]) (define (indent-jsonic tbox [posn 0])
(define prev-line (previous-line tbox posn)) (define prev-line (previous-line tbox posn))
(define current-line (line tbox posn)) (define current-line (line tbox posn))
(cond
[(not prev-line) 0]
[else
(define prev-indent (line-indent tbox prev-line)) (define prev-indent (line-indent tbox prev-line))
(cond (cond
[(left-bracket? [(left-bracket?
@ -16,7 +19,7 @@
[(right-bracket? [(right-bracket?
(line-first-visible-char tbox current-line)) (line-first-visible-char tbox current-line))
(- prev-indent indent-width)] (- prev-indent indent-width)]
[else prev-indent])) [else prev-indent])]))
(provide (provide
(contract-out (contract-out
[indent-jsonic (((is-a?/c text%)) [indent-jsonic (((is-a?/c text%))
@ -28,7 +31,7 @@
(define test-str #<<HERE (define test-str #<<HERE
#lang jsonic #lang jsonic
{ {
"value", "value": 42,
"string": "string":
[ [
{ {

@ -8,6 +8,9 @@
(define (indent-jsonic tbox [posn 0]) (define (indent-jsonic tbox [posn 0])
(define prev-line (previous-line tbox posn)) (define prev-line (previous-line tbox posn))
(define current-line (line tbox posn)) (define current-line (line tbox posn))
(cond
[(not prev-line) 0]
[else
(define prev-indent (line-indent tbox prev-line)) (define prev-indent (line-indent tbox prev-line))
(cond (cond
[(left-bracket? [(left-bracket?
@ -16,7 +19,7 @@
[(right-bracket? [(right-bracket?
(line-first-visible-char tbox current-line)) (line-first-visible-char tbox current-line))
(- prev-indent indent-width)] (- prev-indent indent-width)]
[else prev-indent])) [else prev-indent])]))
(provide (provide
(contract-out (contract-out
[indent-jsonic (((is-a?/c text%)) [indent-jsonic (((is-a?/c text%))
@ -28,7 +31,7 @@
(define test-str #<<HERE (define test-str #<<HERE
#lang jsonic #lang jsonic
{ {
"value", "value": 42,
"string": "string":
[ [
{ {

Loading…
Cancel
Save