|
139 | 139 | (defn slurp [direction]
|
140 | 140 | (fn [^js state]
|
141 | 141 | (u/update-ranges state
|
142 |
| - (j/fn [^:js {:as range :keys [from to empty]}] |
| 142 | + (j/fn [^:js {:keys [from empty]}] |
143 | 143 | (when empty
|
144 | 144 | (when-let [parent (n/closest (n/tree state from)
|
145 |
| - (every-pred n/coll? |
| 145 | + (every-pred (some-fn n/coll? |
| 146 | + n/string?) |
146 | 147 | #(not
|
147 | 148 | (case direction
|
148 | 149 | 1 (some-> % n/with-prefix n/right n/end-edge?)
|
149 |
| - -1 (some-> % n/with-prefix n/left n/start-edge?)))))] |
150 |
| - (when-let [target (case direction 1 (first (remove n/line-comment? (n/rights (n/with-prefix parent)))) |
151 |
| - -1 (first (remove n/line-comment? (n/lefts (n/with-prefix parent)))))] |
152 |
| - {:cursor/mapped from |
153 |
| - :changes (case direction |
154 |
| - 1 |
155 |
| - (let [edge (n/down-last parent)] |
156 |
| - [{:from (-> target n/end) |
157 |
| - :insert (n/name edge)} |
158 |
| - (-> edge |
159 |
| - n/from-to |
160 |
| - (j/assoc! :insert " "))]) |
161 |
| - -1 |
162 |
| - (let [^string edge (n/left-edge-with-prefix state parent) |
163 |
| - start (n/start (n/with-prefix parent))] |
164 |
| - [{:from start |
165 |
| - :to (+ start (count edge)) |
166 |
| - :insert " "} |
167 |
| - {:from (n/start target) |
168 |
| - :insert edge}]))}))))))) |
| 150 | + -1 (some-> % n/with-prefix n/left n/start-edge?)))))] |
| 151 | + (let [str? (n/string? parent)] |
| 152 | + (when-let [target (case direction 1 (first (remove n/line-comment? (n/rights (n/with-prefix parent)))) |
| 153 | + -1 (first (remove n/line-comment? (n/lefts (n/with-prefix parent)))))] |
| 154 | + (js/console.log :target target) |
| 155 | + {:cursor/mapped from |
| 156 | + :changes (case direction |
| 157 | + 1 |
| 158 | + (let [edge (n/down-last parent)] |
| 159 | + [{:from (-> target n/end) |
| 160 | + :insert (n/name edge)} |
| 161 | + (-> edge |
| 162 | + n/from-to |
| 163 | + (cond-> |
| 164 | + (not str?) (j/assoc! :insert " ")))]) |
| 165 | + -1 |
| 166 | + (let [^string edge (n/left-edge-with-prefix state parent) |
| 167 | + start (n/start (n/with-prefix parent))] |
| 168 | + [{:from start |
| 169 | + :to (+ start (count edge)) |
| 170 | + :insert " "} |
| 171 | + {:from (n/start target) |
| 172 | + :insert edge}]))})))))))) |
169 | 173 |
|
170 | 174 | (defn barf [direction]
|
171 | 175 | (fn [^js state]
|
172 |
| - (->> (j/fn [^:js {:as range :keys [from to empty]}] |
| 176 | + (->> (j/fn [^:js {:keys [from empty]}] |
173 | 177 | (when empty
|
174 | 178 | (when-let [parent (-> (n/tree state from)
|
175 | 179 | (n/closest n/coll?))]
|
|
0 commit comments