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) {
155
155
156
156
function viml_len ( obj ) {
157
157
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 ;
159
164
}
160
165
return obj . length ;
161
166
}
Original file line number Diff line number Diff line change @@ -155,7 +155,12 @@ function viml_keys(obj) {
155
155
156
156
function viml_len ( obj ) {
157
157
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 ;
159
164
}
160
165
return obj . length ;
161
166
}
Original file line number Diff line number Diff line change 53
53
(let %= a 5)
54
54
(let ..= a 'foo')
55
55
(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
58
58
let a % = 5
59
59
let a ..= ' foo'
60
60
echo (' foo' .. ' bar' )..' baz'
61
+ let a = ' 🐥'
You can’t perform that action at this time.
0 commit comments