don't forget this case

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

@ -8,15 +8,18 @@
(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))
(define prev-indent (line-indent tbox prev-line))
(cond (cond
[(left-bracket? [(not prev-line) 0]
(line-first-visible-char tbox prev-line)) [else
(+ prev-indent indent-width)] (define prev-indent (line-indent tbox prev-line))
[(right-bracket? (cond
(line-first-visible-char tbox current-line)) [(left-bracket?
(- prev-indent indent-width)] (line-first-visible-char tbox prev-line))
[else prev-indent])) (+ prev-indent indent-width)]
[(right-bracket?
(line-first-visible-char tbox current-line))
(- prev-indent indent-width)]
[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,15 +8,18 @@
(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))
(define prev-indent (line-indent tbox prev-line))
(cond (cond
[(left-bracket? [(not prev-line) 0]
(line-first-visible-char tbox prev-line)) [else
(+ prev-indent indent-width)] (define prev-indent (line-indent tbox prev-line))
[(right-bracket? (cond
(line-first-visible-char tbox current-line)) [(left-bracket?
(- prev-indent indent-width)] (line-first-visible-char tbox prev-line))
[else prev-indent])) (+ prev-indent indent-width)]
[(right-bracket?
(line-first-visible-char tbox current-line))
(- prev-indent indent-width)]
[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