@@ -38,7 +38,7 @@ define(function (require, exports, module) {
3838 while ( start > 0 ) {
3939 const char = line . charAt ( start - 1 ) ;
4040 // Include the valid Emmet characters such as : + * >
41- if ( / [ a - z A - Z 0 - 9 : + * > ! \- @ . # ] / . test ( char ) ) {
41+ if ( / [ a - z A - Z 0 - 9 : + * > ! \- @ . # { } ] / . test ( char ) ) {
4242 start -- ;
4343 } else {
4444 break ;
@@ -78,7 +78,7 @@ define(function (require, exports, module) {
7878 }
7979
8080 /**
81- *
81+ * Responsible to expand the markup abbreviation
8282 *
8383 * @param {Editor } editor - The editor instance
8484 * @param {Object } word - The word object, refer to `getWordBeforeCursor` function
@@ -92,12 +92,33 @@ define(function (require, exports, module) {
9292
9393 if ( expanded ) {
9494
95+ // this check is added because in some situations such as
96+ // `ul>li{Hello}` and the cursor is before the closing braces right after 'o',
97+ // then when this is expanded it results in an extra closing braces at the end.
98+ // so we remove the extra ' }' from the end
99+ if ( word . word . includes ( '{' ) ) {
100+ const pos = editor . getCursorPos ( ) ;
101+ const line = editor . document . getLine ( pos . line ) ;
102+ const char = line . charAt ( word . end . ch ) ;
103+
104+ if ( char === '}' ) {
105+ word . end . ch += 1 ;
106+ editor . document . replaceRange (
107+ expanded ,
108+ word . start ,
109+ word . end
110+ ) ;
111+ return true ;
112+ }
113+
114+ }
95115 // replace the existing abbreviation with the expanded version
96116 editor . document . replaceRange (
97117 expanded ,
98118 word . start ,
99119 word . end
100120 ) ;
121+
101122 return true ;
102123 }
103124
0 commit comments