@@ -134,8 +134,8 @@ var foldingRangeUp = {
134134 end : new Pos ( foldingStart . line , 0 )
135135} ;
136136
137- function copyCursor ( cur ) {
138- return new Pos ( cur . line , cur . ch ) ;
137+ function searchHighlighted ( vim ) {
138+ return vim . searchState_ && ( vim . searchState_ . getOverlay ( ) || vim . searchState_ . highlightTimeout ) ;
139139}
140140
141141function forEach ( arr , func ) {
@@ -4459,6 +4459,13 @@ testVim('ex_substitute_empty_arguments', function(cm,vim,helpers) {
44594459 helpers . doEx ( 's' ) ;
44604460 eq ( 'b b\nb a' , cm . getValue ( ) ) ;
44614461} , { value : 'a a\na a' } ) ;
4462+ testVim ( 'ex_substitute_highlight' , function ( cm , vim , helpers ) {
4463+ is ( ! searchHighlighted ( vim ) ) ;
4464+ helpers . doKeys ( ':s/a' ) ;
4465+ is ( searchHighlighted ( vim ) ) ;
4466+ helpers . doKeys ( '\n' ) ;
4467+ is ( ! searchHighlighted ( vim ) ) ;
4468+ } , { value : 'a a\na a' } ) ;
44624469
44634470// More complex substitute tests that test both pcre and nopcre options.
44644471function testSubstitute ( name , options ) {
@@ -4690,9 +4697,11 @@ testSubstituteConfirm('ex_substitute_confirm_range_last',
46904697 '1,3s/a/b/cg' , 'aa\na \na\na' , 'bb\nb \na\na' , 'yyl' , makeCursor ( 1 , 0 ) ) ;
46914698//:noh should clear highlighting of search-results but allow to resume search through n
46924699testVim ( 'ex_noh_clearSearchHighlight' , function ( cm , vim , helpers ) {
4700+ is ( ! searchHighlighted ( vim ) )
46934701 helpers . doKeys ( '?' , 'match' , '\n' ) ;
4702+ is ( searchHighlighted ( vim ) )
46944703 helpers . doEx ( 'noh' ) ;
4695- eq ( vim . searchState_ . getOverlay ( ) , null , 'match-highlighting wasn\'t cleared' ) ;
4704+ is ( ! searchHighlighted ( vim ) ) ;
46964705 helpers . doKeys ( 'n' ) ;
46974706 helpers . assertCursorAt ( 0 , 11 , 'can\'t resume search after clearing highlighting' ) ;
46984707} , { value : 'match nope match \n nope Match' } ) ;
@@ -4864,17 +4873,14 @@ testVim('ex_set_filetype_null', function(cm, vim, helpers) {
48644873} ) ;
48654874
48664875testVim ( 'map_prompt' , function ( cm , vim , helpers ) {
4867- function highlighted ( ) {
4868- return vim . searchState_ && ( vim . searchState_ . getOverlay ( ) || vim . searchState_ . highlightTimeout ) ;
4869- }
4870- is ( ! highlighted ( ) ) ;
4876+ is ( ! searchHighlighted ( vim ) ) ;
48714877
48724878 helpers . doKeys ( '/a\n' ) ;
48734879 helpers . doKeys ( 'i' ) ;
4874- is ( highlighted ( ) ) ;
4880+ is ( searchHighlighted ( vim ) ) ;
48754881 helpers . doKeys ( '<Esc>' ) ;
48764882 helpers . doEx ( 'nohl' ) ;
4877- is ( ! highlighted ( ) ) ;
4883+ is ( ! searchHighlighted ( vim ) ) ;
48784884 helpers . assertCursorAt ( 1 , 2 ) ;
48794885
48804886 helpers . doEx ( 'nnoremap i :nohl<CR>i<space>xx<lt>' ) ;
@@ -4887,9 +4893,9 @@ testVim('map_prompt', function(cm, vim, helpers) {
48874893 helpers . doKeys ( 'j' ) ;
48884894 eq ( cm . getWrapperElement ( ) . querySelector ( "input" ) . value , "ab" ) ;
48894895 helpers . doKeys ( '<CR>' ) ;
4890- is ( highlighted ( ) ) ;
4896+ is ( searchHighlighted ( vim ) ) ;
48914897 helpers . doKeys ( 'i' ) ;
4892- is ( ! highlighted ( ) ) ;
4898+ is ( ! searchHighlighted ( vim ) ) ;
48934899
48944900 eq ( cm . getValue ( ) , ' 0 xyz\n hi1 xx<abc \n 2 abc' ) ;
48954901
0 commit comments