Improve printing of patches
This commit is contained in:
parent
129dd23b84
commit
2a2d363c5e
|
@ -49,6 +49,7 @@
|
|||
|
||||
(require racket/set)
|
||||
(require racket/match)
|
||||
(require (only-in racket/string string-trim))
|
||||
(require "trie.rkt")
|
||||
(require "tset.rkt")
|
||||
(require "pretty.rkt")
|
||||
|
@ -294,9 +295,9 @@
|
|||
|
||||
(define (patch->pretty-string p)
|
||||
(match-define (patch in out) p)
|
||||
(format "<<<<<<<< Removed:\n~a======== Added:\n~a>>>>>>>>\n"
|
||||
(trie->pretty-string out)
|
||||
(trie->pretty-string in)))
|
||||
(format "-~a\n+~a\n"
|
||||
(string-trim #:left? #f (trie->pretty-string out #:indent "-"))
|
||||
(string-trim #:left? #f (trie->pretty-string in #:indent "+"))))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
|
|
|
@ -951,10 +951,10 @@
|
|||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
;; Trie [OutputPort] [#:indent Nat] [#:with-parens Boolean] -> Trie
|
||||
;; Trie [OutputPort] [#:indent (U Nat String)] [#:with-parens Boolean] -> Trie
|
||||
;; Pretty-prints the given trie on the given port, with
|
||||
;; second-and-subsequent lines indented by the given amount.
|
||||
;; Returns the trie.
|
||||
;; second-and-subsequent lines indented by the given amount (or the
|
||||
;; given prefix). Returns the trie.
|
||||
(define (pretty-print-trie m [port (current-output-port)]
|
||||
#:indent [initial-indent 0]
|
||||
#:with-parens [with-parens #f])
|
||||
|
@ -996,7 +996,10 @@
|
|||
(when with-parens
|
||||
(display "{{" port)
|
||||
(newline port))
|
||||
(walk (make-string initial-indent #\space) m)
|
||||
(walk (if (string? initial-indent)
|
||||
initial-indent
|
||||
(make-string initial-indent #\space))
|
||||
m)
|
||||
(newline port)
|
||||
(if with-parens
|
||||
(display "}}" port)
|
||||
|
|
Loading…
Reference in New Issue