@@ -407,12 +407,35 @@ define(function (require, exports, module) {
407407 expandedAbbr = expandedAbbr . split ( ':' ) [ 0 ] ;
408408 }
409409
410+ // token is required for highlighting the matched part. It gives access to
411+ // stringRanges property. Refer to `formatHints()` function in this file for more detail
412+ const [ token ] = StringMatch . codeHintsSort ( needle , [ expandedAbbr ] ) ;
413+
410414 // this displays an emmet icon at the side of the hint
411415 // this gives an idea to the user that the hint is coming from Emmet
412416 let $icon = $ ( `<span class="emmet-css-code-hint">Emmet</span>` ) ;
413417
414- const $emmetHintObj = $ ( `<span data-val='${ expandedAbbr } '></span>` ) . addClass ( "brackets-css-hints brackets-hints" ) ;
415- $emmetHintObj . text ( expandedAbbr ) ;
418+ const $emmetHintObj = $ ( "<span>" )
419+ . addClass ( "brackets-css-hints brackets-hints" )
420+ . attr ( "data-val" , expandedAbbr ) ;
421+
422+ // for highlighting the already-typed characters
423+ if ( token . stringRanges ) {
424+ token . stringRanges . forEach ( function ( range ) {
425+ if ( range . matched ) {
426+ $emmetHintObj . append ( $ ( "<span>" )
427+ . text ( range . text )
428+ . addClass ( "matched-hint" ) ) ;
429+ } else {
430+ $emmetHintObj . append ( range . text ) ;
431+ }
432+ } ) ;
433+ } else {
434+ // fallback
435+ $emmetHintObj . text ( expandedAbbr ) ;
436+ }
437+
438+ // add the emmet icon to the final hint object
416439 $emmetHintObj . append ( $icon ) ;
417440
418441 if ( pushedHints ) {
@@ -435,8 +458,6 @@ define(function (require, exports, module) {
435458 }
436459 }
437460
438-
439-
440461 return {
441462 hints : pushedHints ,
442463 match : null , // the CodeHintManager should not format the results
0 commit comments