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 66 SelectWord ,
77 TextObject ,
88} from '../../textobject/textobject' ;
9+ import { WordType } from '../../textobject/word' ;
910import { isIMovement } from '../baseMotion' ;
1011import {
1112 MoveAroundBacktick ,
@@ -585,11 +586,11 @@ class SurroundHelper {
585586 // start -> <foo>bar</foo> <-- stop
586587 const openTagNameStart = rangeStart . getRight ( ) ;
587588 const openTagNameEnd = openTagNameStart
588- . nextWordEnd ( vimState . document , { inclusive : true } )
589+ . nextWordEnd ( vimState . document , { wordType : WordType . TagName , inclusive : true } )
589590 . getRight ( ) ;
590591 const closeTagNameStart = rangeEnd
591592 . getLeft ( 2 )
592- . prevWordStart ( vimState . document , { inclusive : true } ) ;
593+ . prevWordStart ( vimState . document , { wordType : WordType . TagName , inclusive : true } ) ;
593594 const closeTagNameEnd = rangeEnd . getLeft ( ) ;
594595 vimState . cursorStartPosition = position ; // some textobj (MoveInsideCharacter) expect this
595596 vimState . cursorStopPosition = position ;
Original file line number Diff line number Diff line change @@ -8,10 +8,12 @@ export enum WordType {
88 Big ,
99 CamelCase ,
1010 FileName ,
11+ TagName ,
1112}
1213
1314const nonBigWordCharRegex = makeWordRegex ( '' ) ;
1415const nonFileNameRegex = makeWordRegex ( '"\'`;<>{}[]()' ) ;
16+ const nonTagNameRegex = makeWordRegex ( '</>' ) ;
1517
1618function regexForWordType ( wordType : WordType ) : RegExp {
1719 switch ( wordType ) {
@@ -23,6 +25,8 @@ function regexForWordType(wordType: WordType): RegExp {
2325 return makeCamelCaseWordRegex ( configuration . iskeyword ) ;
2426 case WordType . FileName :
2527 return nonFileNameRegex ;
28+ case WordType . TagName :
29+ return nonTagNameRegex ;
2630 }
2731}
2832
Original file line number Diff line number Diff line change @@ -456,6 +456,18 @@ suite('surround plugin', () => {
456456 } ,
457457 } ) ;
458458
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+
459471 newTest ( {
460472 title : 'change surround with tags that contain an attribute and remove them' ,
461473 start : [ '<h2 test class="foo">b|ar</h2>' ] ,
You can’t perform that action at this time.
0 commit comments