(nodeId: string, target: RevealTarget)
| 97 | } |
| 98 | |
| 99 | setNodeSelection(nodeId: string, target: RevealTarget) { |
| 100 | const node = this.tree.node(nodeId); |
| 101 | if (!node) { |
| 102 | return; |
| 103 | } |
| 104 | |
| 105 | let offset = 0; |
| 106 | let length = 0; |
| 107 | |
| 108 | if (target === "graphNode" || target === "keyValue") { |
| 109 | offset = node.boundOffset; |
| 110 | length = node.boundLength; |
| 111 | } else if (target === "key") { |
| 112 | offset = node.boundOffset; |
| 113 | length = node.keyLength + 2; |
| 114 | } else if (target === "value") { |
| 115 | offset = node.offset; |
| 116 | length = node.length; |
| 117 | } |
| 118 | |
| 119 | if (length === 0) { |
| 120 | return; |
| 121 | } |
| 122 | |
| 123 | this.revealOffset(offset + 1); |
| 124 | const range = this.range(offset, length); |
| 125 | this.editor.setSelection(range); |
| 126 | } |
| 127 | |
| 128 | setTree({ treeObject }: ParsedTree, resetCursor: boolean = true) { |
| 129 | const tree = Tree.fromObject(treeObject); |
no test coverage detected