sendkeys: Fix `\n` to `{enter}` conversion

rhansen-sendkeys
Richard Hansen 2021-08-21 04:42:47 -04:00 committed by SamTV12345
parent ed991419b8
commit cff205dbd7
1 changed files with 2 additions and 1 deletions

View File

@ -35,7 +35,8 @@ $.fn.sendkeys = function (x, opts){
$(this).trigger({type: 'beforesendkeys', which: x});
this.focus();
$.data(this, 'sendkeys.originalText', rng.text());
x.replace(/([^{])\n/g, '$1{enter}'). // turn line feeds into explicit break insertions, but not if escaped
// turn line feeds into explicit break insertions, but not if escaped
x.replace(/{[^}]*}|[^{]+/g, (s) => s.startsWith('{') ? s : s.replace(/\n/g, '{enter}')).
replace(/{[^}]*}|[^{]+/g, function(s){
(localkeys[s] || $.fn.sendkeys.defaults[s] || $.fn.sendkeys.defaults.simplechar)(rng, s);
rng.select();