@@ -148,8 +148,10 @@ function* emitKeys(stream) {
148
148
*
149
149
* - `;5` part is optional, e.g. it could be `\x1b[24~`
150
150
* - first part can contain one or two digits
151
+ * - there is also special case when there can be 3 digits
152
+ * but without modifier. They are the case of paste bracket mode
151
153
*
152
- * So the generic regexp is like /^\d\d?(;\d)?[~^$]$/
154
+ * So the generic regexp is like /^(?: \d\d?(;\d)?[~^$]|\d{3}~) $/
153
155
*
154
156
*
155
157
* 2. `\x1b[1;5H` should be parsed as { code: '[H', modifier: 5 }
@@ -170,6 +172,10 @@ function* emitKeys(stream) {
170
172
171
173
if ( ch >= '0' && ch <= '9' ) {
172
174
s += ( ch = yield ) ;
175
+
176
+ if ( ch >= '0' && ch <= '9' ) {
177
+ s += ( ch = yield ) ;
178
+ }
173
179
}
174
180
}
175
181
@@ -189,9 +195,13 @@ function* emitKeys(stream) {
189
195
const cmd = StringPrototypeSlice ( s , cmdStart ) ;
190
196
let match ;
191
197
192
- if ( ( match = RegExpPrototypeExec ( / ^ ( \d \d ? ) ( ; ( \d ) ) ? ( [ ~ ^ $ ] ) $ / , cmd ) ) ) {
193
- code += match [ 1 ] + match [ 4 ] ;
194
- modifier = ( match [ 3 ] || 1 ) - 1 ;
198
+ if ( ( match = RegExpPrototypeExec ( / ^ (?: ( \d \d ? ) (?: ; ( \d ) ) ? ( [ ~ ^ $ ] ) | ( \d { 3 } ~ ) ) $ / , cmd ) ) ) {
199
+ if ( match [ 4 ] ) {
200
+ code += match [ 4 ] ;
201
+ } else {
202
+ code += match [ 1 ] + match [ 3 ] ;
203
+ modifier = ( match [ 2 ] || 1 ) - 1 ;
204
+ }
195
205
} else if (
196
206
( match = RegExpPrototypeExec ( / ^ ( ( \d ; ) ? ( \d ) ) ? ( [ A - Z a - z ] ) $ / , cmd ) )
197
207
) {
@@ -228,6 +238,10 @@ function* emitKeys(stream) {
228
238
case '[13~' : key . name = 'f3' ; break ;
229
239
case '[14~' : key . name = 'f4' ; break ;
230
240
241
+ /* paste bracket mode */
242
+ case '[200~' : key . name = 'paste-start' ; break ;
243
+ case '[201~' : key . name = 'paste-end' ; break ;
244
+
231
245
/* from Cygwin and used in libuv */
232
246
case '[[A' : key . name = 'f1' ; break ;
233
247
case '[[B' : key . name = 'f2' ; break ;
0 commit comments