Commit fdbc04a
authored
[vim bindings] Support tag text objects in xml / htmlmixed mode
User can use `t` to operate on tag text objects. For example, given the
following html:
```
<div>
<span>hello world!</span>
</div>
```
If the user's cursor (denoted by █) is inside "hello world!":
```
<div>
<span>hello█world!</span>
</div>
```
And they enter `dit` (delete inner tag), then the text inside the
enclosing tag is deleted -- the following is the expected result:
```
<div>
<span></span>
</div>
```
If they enter `dat` (delete around tag), then the surrounding tags are
deleted as well:
```
<div>
</div>
```
This logic depends on the following:
- mode/xml/xml.js
- addon/fold/xml-fold.js
- editor is in htmlmixedmode / xml mode
Caveats
This is _NOT_ a 100% accurate implementation of vim tag text objects.
For example, the following cases noop / are inconsistent with vim
behavior:
- Does not work inside comments:
```
<!-- <div>broken</div> -->
```
- Does not work when tags have different cases:
```
<div>broken</DIV>
```
- Does not work when inside a broken tag:
```
<div><brok><en></div>
```
This addresses codemirror#3828.1 parent 772d09e commit fdbc04a
3 files changed
Lines changed: 75 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2069 | 2069 | | |
2070 | 2070 | | |
2071 | 2071 | | |
| 2072 | + | |
| 2073 | + | |
2072 | 2074 | | |
2073 | 2075 | | |
2074 | 2076 | | |
| |||
3295 | 3297 | | |
3296 | 3298 | | |
3297 | 3299 | | |
| 3300 | + | |
| 3301 | + | |
| 3302 | + | |
| 3303 | + | |
| 3304 | + | |
| 3305 | + | |
| 3306 | + | |
| 3307 | + | |
| 3308 | + | |
| 3309 | + | |
| 3310 | + | |
| 3311 | + | |
| 3312 | + | |
| 3313 | + | |
| 3314 | + | |
| 3315 | + | |
| 3316 | + | |
| 3317 | + | |
| 3318 | + | |
| 3319 | + | |
| 3320 | + | |
| 3321 | + | |
| 3322 | + | |
| 3323 | + | |
| 3324 | + | |
| 3325 | + | |
| 3326 | + | |
| 3327 | + | |
| 3328 | + | |
| 3329 | + | |
| 3330 | + | |
| 3331 | + | |
| 3332 | + | |
| 3333 | + | |
| 3334 | + | |
| 3335 | + | |
| 3336 | + | |
| 3337 | + | |
| 3338 | + | |
| 3339 | + | |
| 3340 | + | |
| 3341 | + | |
| 3342 | + | |
3298 | 3343 | | |
3299 | 3344 | | |
3300 | 3345 | | |
| |||
3836 | 3881 | | |
3837 | 3882 | | |
3838 | 3883 | | |
3839 | | - | |
| 3884 | + | |
3840 | 3885 | | |
3841 | 3886 | | |
3842 | 3887 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
156 | 156 | | |
157 | 157 | | |
158 | 158 | | |
| 159 | + | |
159 | 160 | | |
160 | 161 | | |
161 | 162 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1317 | 1317 | | |
1318 | 1318 | | |
1319 | 1319 | | |
1320 | | - | |
1321 | | - | |
| 1320 | + | |
| 1321 | + | |
| 1322 | + | |
1322 | 1323 | | |
| 1324 | + | |
| 1325 | + | |
| 1326 | + | |
1323 | 1327 | | |
1324 | 1328 | | |
1325 | 1329 | | |
| |||
1424 | 1428 | | |
1425 | 1429 | | |
1426 | 1430 | | |
| 1431 | + | |
| 1432 | + | |
| 1433 | + | |
| 1434 | + | |
| 1435 | + | |
| 1436 | + | |
| 1437 | + | |
| 1438 | + | |
| 1439 | + | |
| 1440 | + | |
| 1441 | + | |
| 1442 | + | |
| 1443 | + | |
| 1444 | + | |
| 1445 | + | |
| 1446 | + | |
| 1447 | + | |
| 1448 | + | |
| 1449 | + | |
| 1450 | + | |
| 1451 | + | |
| 1452 | + | |
1427 | 1453 | | |
1428 | 1454 | | |
1429 | 1455 | | |
| |||
0 commit comments