{ "area": "decorations", "cases": [ { "name": "underline: insertion at the start is not extended", "text": "if T[j] < T[i]:\n m = j\nend", "ops": [{ "op": "decorate", "items": [{ "kind": "underline", "start": 10, "end": 14 }] }, { "op": "replace", "start": 10, "end": 10, "text": "x" }], "expect": { "decorations": [{ "kind": "underline", "start": 11, "end": 15 }] } }, { "name": "underline: insertion at the end is not extended", "text": "if T[j] < T[i]:\n m = j\nend", "ops": [{ "op": "decorate", "items": [{ "kind": "underline", "start": 10, "end": 14 }] }, { "op": "replace", "start": 14, "end": 14, "text": "x" }], "expect": { "decorations": [{ "kind": "underline", "start": 10, "end": 14 }] } }, { "name": "underline: typing inside extends it", "text": "if T[j] < T[i]:\n m = j\nend", "ops": [{ "op": "decorate", "items": [{ "kind": "underline", "start": 10, "end": 14 }] }, { "op": "setSelection", "anchor": 12, "head": 12 }, { "op": "type", "text": "x" }], "expect": { "text": "if T[j] < T[xi]:\n m = j\nend", "decorations": [{ "kind": "underline", "start": 10, "end": 15 }] } }, { "name": "underline: an edit before shifts it", "text": "if T[j] < T[i]:\n m = j\nend", "ops": [{ "op": "decorate", "items": [{ "kind": "underline", "start": 10, "end": 14 }] }, { "op": "replace", "start": 3, "end": 4, "text": "AB" }], "expect": { "decorations": [{ "kind": "underline", "start": 11, "end": 15 }] } }, { "name": "underline: an edit after leaves it", "text": "if T[j] < T[i]:\n m = j\nend", "ops": [{ "op": "decorate", "items": [{ "kind": "underline", "start": 10, "end": 14 }] }, { "op": "replace", "start": 16, "end": 20, "text": "" }], "expect": { "decorations": [{ "kind": "underline", "start": 10, "end": 14 }] } }, { "name": "underline: replacing exactly the range keeps it on the new text", "text": "if T[j] < T[i]:\n m = j\nend", "ops": [{ "op": "decorate", "items": [{ "kind": "underline", "start": 10, "end": 14 }] }, { "op": "replace", "start": 10, "end": 14, "text": "T[min]" }], "expect": { "decorations": [{ "kind": "underline", "start": 10, "end": 16 }] } }, { "name": "underline: deleting exactly the range removes it", "text": "if T[j] < T[i]:\n m = j\nend", "ops": [{ "op": "decorate", "items": [{ "kind": "underline", "start": 10, "end": 14 }] }, { "op": "replace", "start": 10, "end": 14, "text": "" }], "expect": { "decorations": [] } }, { "name": "underline: a paste over a larger region removes it", "text": "if T[j] < T[i]:\n m = j\nend", "ops": [{ "op": "decorate", "items": [{ "kind": "underline", "start": 10, "end": 14 }] }, { "op": "replace", "start": 8, "end": 15, "text": "x" }], "expect": { "decorations": [] } }, { "name": "underline: a replacement across the start keeps the original remainder", "text": "if T[j] < T[i]:\n m = j\nend", "ops": [{ "op": "decorate", "items": [{ "kind": "underline", "start": 10, "end": 14 }] }, { "op": "replace", "start": 8, "end": 12, "text": "QQ" }], "expect": { "text": "if T[j] QQi]:\n m = j\nend", "decorations": [{ "kind": "underline", "start": 10, "end": 12 }] } }, { "name": "underline: a replacement across the end keeps the original remainder", "text": "if T[j] < T[i]:\n m = j\nend", "ops": [{ "op": "decorate", "items": [{ "kind": "underline", "start": 10, "end": 14 }] }, { "op": "replace", "start": 12, "end": 16, "text": "Z" }], "expect": { "text": "if T[j] < T[Z m = j\nend", "decorations": [{ "kind": "underline", "start": 10, "end": 12 }] } }, { "name": "underline: setText clears it", "text": "if T[j] < T[i]:\n m = j\nend", "ops": [{ "op": "decorate", "items": [{ "kind": "underline", "start": 10, "end": 14 }] }, { "op": "setText", "text": "abc" }], "expect": { "decorations": [] } }, { "name": "underline: undo after the removing edit leaves it removed", "text": "if T[j] < T[i]:\n m = j\nend", "ops": [{ "op": "decorate", "items": [{ "kind": "underline", "start": 10, "end": 14 }] }, { "op": "replace", "start": 10, "end": 14, "text": "" }, { "op": "undo" }], "expect": { "text": "if T[j] < T[i]:\n m = j\nend", "decorations": [] } }, { "name": "underline: a range past the document end is clamped, then dropped when empty", "text": "if T[j] < T[i]:\n m = j\nend", "ops": [{ "op": "decorate", "items": [{ "kind": "underline", "start": 20, "end": 40 }, { "kind": "underline", "start": 35, "end": 40 }] }], "expect": { "decorations": [{ "kind": "underline", "start": 20, "end": 29 }] } }, { "name": "underline: an empty range is dropped", "text": "if T[j] < T[i]:\n m = j\nend", "ops": [{ "op": "decorate", "items": [{ "kind": "underline", "start": 5, "end": 5 }] }], "expect": { "decorations": [] } }, { "name": "gap: typing at the end of its line keeps it", "text": "if T[j] < T[i]:\n m = j\nend", "ops": [{ "op": "decorate", "items": [{ "kind": "gap", "line": 0, "rows": 2 }] }, { "op": "replace", "start": 15, "end": 15, "text": "x" }], "expect": { "decorations": [{ "kind": "gap", "line": 0, "rows": 2 }] } }, { "name": "gap: Enter at the very end keeps it on the line", "text": "if T[j] < T[i]:\n m = j\nend", "ops": [{ "op": "decorate", "items": [{ "kind": "gap", "line": 0, "rows": 2 }] }, { "op": "replace", "start": 15, "end": 15, "text": "\n" }], "expect": { "lineCount": 4, "decorations": [{ "kind": "gap", "line": 0, "rows": 2 }] } }, { "name": "gap: Enter in the middle moves it to the second half", "text": "if T[j] < T[i]:\n m = j\nend", "ops": [{ "op": "decorate", "items": [{ "kind": "gap", "line": 0, "rows": 2 }] }, { "op": "replace", "start": 8, "end": 8, "text": "\n" }], "expect": { "decorations": [{ "kind": "gap", "line": 1, "rows": 2 }] } }, { "name": "gap: Enter at the line start moves it down one line", "text": "if T[j] < T[i]:\n m = j\nend", "ops": [{ "op": "decorate", "items": [{ "kind": "gap", "line": 1, "rows": 2 }] }, { "op": "replace", "start": 16, "end": 16, "text": "\n" }], "expect": { "decorations": [{ "kind": "gap", "line": 2, "rows": 2 }] } }, { "name": "gap: joining the next line adds its rows", "text": "if T[j] < T[i]:\n m = j\nend", "ops": [{ "op": "decorate", "items": [{ "kind": "gap", "line": 0, "rows": 2 }, { "kind": "gap", "line": 1, "rows": 1 }] }, { "op": "replace", "start": 15, "end": 16, "text": "" }], "expect": { "decorations": [{ "kind": "gap", "line": 0, "rows": 2 }, { "kind": "gap", "line": 0, "rows": 1 }], "gapRows": { "0": 3 } } }, { "name": "gap: deleting the line removes it", "text": "if T[j] < T[i]:\n m = j\nend", "ops": [{ "op": "decorate", "items": [{ "kind": "gap", "line": 1, "rows": 2 }] }, { "op": "replace", "start": 16, "end": 26, "text": "" }], "expect": { "decorations": [] } }, { "name": "gap: replacing the line's text keeps it", "text": "if T[j] < T[i]:\n m = j\nend", "ops": [{ "op": "decorate", "items": [{ "kind": "gap", "line": 1, "rows": 2 }] }, { "op": "replace", "start": 16, "end": 25, "text": "k = 0" }], "expect": { "decorations": [{ "kind": "gap", "line": 1, "rows": 2 }] } }, { "name": "gap: deleting from the middle of the line above through it removes it", "text": "if T[j] < T[i]:\n m = j\nend", "ops": [{ "op": "decorate", "items": [{ "kind": "gap", "line": 1, "rows": 2 }] }, { "op": "replace", "start": 8, "end": 26, "text": "" }], "expect": { "text": "if T[j] end", "decorations": [] } }, { "name": "gap: a line outside the document or zero rows is dropped", "text": "if T[j] < T[i]:\n m = j\nend", "ops": [{ "op": "decorate", "items": [{ "kind": "gap", "line": 5, "rows": 2 }, { "kind": "gap", "line": 0, "rows": 0 }] }], "expect": { "decorations": [] } }, { "name": "lineBackground: Enter in the middle moves it like a gap", "text": "if T[j] < T[i]:\n m = j\nend", "ops": [{ "op": "decorate", "items": [{ "kind": "lineBackground", "line": 0 }] }, { "op": "replace", "start": 8, "end": 8, "text": "\n" }], "expect": { "decorations": [{ "kind": "lineBackground", "line": 1 }] } }, { "name": "revision: a set computed two edits ago is mapped through both", "text": "if T[j] < T[i]:\n m = j\nend", "ops": [{ "op": "replace", "start": 0, "end": 0, "text": "a" }, { "op": "replace", "start": 0, "end": 0, "text": "b" }, { "op": "decorate", "revision": 0, "items": [{ "kind": "underline", "start": 10, "end": 14 }, { "kind": "gap", "line": 1, "rows": 2 }] }], "expect": { "decorations": [{ "kind": "underline", "start": 12, "end": 16 }, { "kind": "gap", "line": 1, "rows": 2 }] } }, { "name": "revision: a set older than the log is ignored and the previous set stays", "text": "if T[j] < T[i]:\n m = j\nend", "ops": [{ "op": "decorate", "items": [{ "kind": "underline", "start": 10, "end": 14 }] }, { "op": "setSelection", "anchor": 29, "head": 29 }, { "op": "type", "text": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, { "op": "decorate", "revision": 0, "items": [{ "kind": "underline", "start": 0, "end": 2 }] }], "expect": { "revision": 257, "decorations": [{ "kind": "underline", "start": 10, "end": 14 }] } }, { "name": "revision: a set older than a setText is ignored", "text": "if T[j] < T[i]:\n m = j\nend", "ops": [{ "op": "setText", "text": "if T[j] < T[i]:\n m = j\nend" }, { "op": "decorate", "revision": 0, "items": [{ "kind": "underline", "start": 0, "end": 2 }] }], "expect": { "decorations": [] } }, { "name": "revision: a revision above the current one is applied as current", "text": "if T[j] < T[i]:\n m = j\nend", "ops": [{ "op": "decorate", "revision": 99, "items": [{ "kind": "underline", "start": 10, "end": 14 }] }], "expect": { "decorations": [{ "kind": "underline", "start": 10, "end": 14 }] } }, { "name": "underline: undo of an edit before it moves it back", "text": "if T[j] < T[i]:\n m = j\nend", "ops": [{ "op": "decorate", "items": [{ "kind": "underline", "start": 10, "end": 14 }] }, { "op": "replace", "start": 0, "end": 0, "text": "a" }, { "op": "undo" }], "expect": { "text": "if T[j] < T[i]:\n m = j\nend", "decorations": [{ "kind": "underline", "start": 10, "end": 14 }] } }, { "name": "underline: redo of an edit before it moves it again", "text": "if T[j] < T[i]:\n m = j\nend", "ops": [{ "op": "decorate", "items": [{ "kind": "underline", "start": 10, "end": 14 }] }, { "op": "replace", "start": 0, "end": 0, "text": "a" }, { "op": "undo" }, { "op": "redo" }], "expect": { "decorations": [{ "kind": "underline", "start": 11, "end": 15 }] } }, { "name": "gap: undo of an Enter above it moves it back", "text": "if T[j] < T[i]:\n m = j\nend", "ops": [{ "op": "decorate", "items": [{ "kind": "gap", "line": 1, "rows": 2 }] }, { "op": "replace", "start": 0, "end": 0, "text": "\n" }, { "op": "undo" }], "expect": { "text": "if T[j] < T[i]:\n m = j\nend", "decorations": [{ "kind": "gap", "line": 1, "rows": 2 }] } }, { "name": "revision: a set computed before an undo is mapped through the undo", "text": "if T[j] < T[i]:\n m = j\nend", "ops": [{ "op": "replace", "start": 0, "end": 0, "text": "a" }, { "op": "undo" }, { "op": "decorate", "revision": 1, "items": [{ "kind": "underline", "start": 11, "end": 15 }] }], "expect": { "decorations": [{ "kind": "underline", "start": 10, "end": 14 }] } }, { "name": "underline: a thickness of zero or less is dropped", "text": "if T[j] < T[i]:\n m = j\nend", "ops": [{ "op": "decorate", "items": [{ "kind": "underline", "start": 10, "end": 14, "thickness": -1 }, { "kind": "underline", "start": 0, "end": 2, "thickness": 0 }, { "kind": "underline", "start": 3, "end": 7, "thickness": 0.5 }] }], "expect": { "decorations": [{ "kind": "underline", "start": 3, "end": 7 }] } } ] }