File tree Expand file tree Collapse file tree 4 files changed +14
-2
lines changed Expand file tree Collapse file tree 4 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -155,7 +155,12 @@ function viml_keys(obj) {
155155
156156function viml_len ( obj ) {
157157 if ( typeof obj === 'string' ) {
158- return encodeURIComponent ( obj ) . replace ( / % ../ g, ' ' ) . length ;
158+ var len = 0 ;
159+ for ( var i = 0 ; i < obj . length ; i ++ ) {
160+ var c = obj . charCodeAt ( i ) ;
161+ len += c < 128 ? 1 : ( ( c > 127 ) && ( c < 2048 ) ) ? 2 : 3 ;
162+ }
163+ return len ;
159164 }
160165 return obj . length ;
161166}
Original file line number Diff line number Diff line change @@ -155,7 +155,12 @@ function viml_keys(obj) {
155155
156156function viml_len ( obj ) {
157157 if ( typeof obj === 'string' ) {
158- return encodeURIComponent ( obj ) . replace ( / % ../ g, ' ' ) . length ;
158+ var len = 0 ;
159+ for ( var i = 0 ; i < obj . length ; i ++ ) {
160+ var c = obj . charCodeAt ( i ) ;
161+ len += c < 128 ? 1 : ( ( c > 127 ) && ( c < 2048 ) ) ? 2 : 3 ;
162+ }
163+ return len ;
159164 }
160165 return obj . length ;
161166}
Original file line number Diff line number Diff line change 5353(let %= a 5)
5454(let ..= a 'foo')
5555(echo (concat (concat 'foo' 'bar') 'baz'))
56+ (let = a '🐥')
Original file line number Diff line number Diff line change @@ -58,3 +58,4 @@ let a /= 4
5858let a % = 5
5959let a ..= ' foo'
6060echo (' foo' .. ' bar' )..' baz'
61+ let a = ' 🐥'
You can’t perform that action at this time.
0 commit comments