Skip to content

Commit 579f1e4

Browse files
committed
Preserve spaces when copying.
1 parent 62f0983 commit 579f1e4

2 files changed

Lines changed: 8 additions & 5 deletions

File tree

internal/explore/render.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ func (w *jsonOutputter) EndMap() {
168168
}
169169
w.pop()
170170
w.newline()
171-
w.Print(w.tabs() + "}")
171+
w.Printf("<span class=\"cp\">%s</span>}", w.tabs())
172172
w.key = false
173173
w.name = ""
174174
w.unfresh()
@@ -188,7 +188,7 @@ func (w *jsonOutputter) EndArray() {
188188
}
189189
w.pop()
190190
w.newline()
191-
w.Print(w.tabs() + "]")
191+
w.Printf("<span class=\"cp\">%s</span>]", w.tabs())
192192
w.key = false
193193
w.unfresh()
194194
}
@@ -223,14 +223,13 @@ func (w *jsonOutputter) Fresh() bool {
223223
}
224224

225225
func (w *jsonOutputter) push() {
226-
w.Print(w.tabs() + `<div class="indent">` + "\n")
226+
w.Print(`<div class="indent">` + "\n")
227227
w.fresh = append(w.fresh, true)
228228
}
229229

230230
func (w *jsonOutputter) pop() {
231231
w.fresh = w.fresh[:len(w.fresh)-1]
232232
w.newline()
233-
w.Print(w.tabs())
234233
w.undiv()
235234
}
236235

@@ -288,7 +287,7 @@ func (w *jsonOutputter) newline() {
288287
}
289288

290289
func (w *jsonOutputter) div() {
291-
w.Print(w.tabs() + "<div>")
290+
w.Print("<div><span class=\"cp\">" + w.tabs() + "</span>")
292291
}
293292

294293
func (w *jsonOutputter) undiv() {

internal/explore/templates.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,10 @@ pre {
249249
margin-left: 2em;
250250
}
251251
252+
.cp {
253+
font-size: 0;
254+
}
255+
252256
.noselect {
253257
user-select: none;
254258
-webkit-user-select: none;

0 commit comments

Comments
 (0)