File tree Expand file tree Collapse file tree 3 files changed +19
-2
lines changed Expand file tree Collapse file tree 3 files changed +19
-2
lines changed Original file line number Diff line number Diff line change 6
6
SelectWord ,
7
7
TextObject ,
8
8
} from '../../textobject/textobject' ;
9
+ import { WordType } from '../../textobject/word' ;
9
10
import { isIMovement } from '../baseMotion' ;
10
11
import {
11
12
MoveAroundBacktick ,
@@ -585,11 +586,11 @@ class SurroundHelper {
585
586
// start -> <foo>bar</foo> <-- stop
586
587
const openTagNameStart = rangeStart . getRight ( ) ;
587
588
const openTagNameEnd = openTagNameStart
588
- . nextWordEnd ( vimState . document , { inclusive : true } )
589
+ . nextWordEnd ( vimState . document , { wordType : WordType . TagName , inclusive : true } )
589
590
. getRight ( ) ;
590
591
const closeTagNameStart = rangeEnd
591
592
. getLeft ( 2 )
592
- . prevWordStart ( vimState . document , { inclusive : true } ) ;
593
+ . prevWordStart ( vimState . document , { wordType : WordType . TagName , inclusive : true } ) ;
593
594
const closeTagNameEnd = rangeEnd . getLeft ( ) ;
594
595
vimState . cursorStartPosition = position ; // some textobj (MoveInsideCharacter) expect this
595
596
vimState . cursorStopPosition = position ;
Original file line number Diff line number Diff line change @@ -8,10 +8,12 @@ export enum WordType {
8
8
Big ,
9
9
CamelCase ,
10
10
FileName ,
11
+ TagName ,
11
12
}
12
13
13
14
const nonBigWordCharRegex = makeWordRegex ( '' ) ;
14
15
const nonFileNameRegex = makeWordRegex ( '"\'`;<>{}[]()' ) ;
16
+ const nonTagNameRegex = makeWordRegex ( '</>' ) ;
15
17
16
18
function regexForWordType ( wordType : WordType ) : RegExp {
17
19
switch ( wordType ) {
@@ -23,6 +25,8 @@ function regexForWordType(wordType: WordType): RegExp {
23
25
return makeCamelCaseWordRegex ( configuration . iskeyword ) ;
24
26
case WordType . FileName :
25
27
return nonFileNameRegex ;
28
+ case WordType . TagName :
29
+ return nonTagNameRegex ;
26
30
}
27
31
}
28
32
Original file line number Diff line number Diff line change @@ -456,6 +456,18 @@ suite('surround plugin', () => {
456
456
} ,
457
457
} ) ;
458
458
459
+ newTest ( {
460
+ title : 'change surround with tags with kebab case names' ,
461
+ start : [ '<custom-tag>|</custom-tag>' ] ,
462
+ keysPressed : 'cstt' ,
463
+ end : [ '<h1>|</h1>' ] ,
464
+ stub : {
465
+ stubClass : CommandSurroundAddSurroundingTag ,
466
+ methodName : 'readTag' ,
467
+ returnValue : 'h1' ,
468
+ } ,
469
+ } ) ;
470
+
459
471
newTest ( {
460
472
title : 'change surround with tags that contain an attribute and remove them' ,
461
473
start : [ '<h2 test class="foo">b|ar</h2>' ] ,
You can’t perform that action at this time.
0 commit comments