mirror of
https://github.com/keymanapp/keyman.git
synced 2026-09-21 07:07:39 +00:00
fix(developer): handle unpaired surrogate
Fixes #7658. When manipulating text that contains an unpaired surrogate, the text editor could throw an exception trying to encode the text to send through to the token command. This simply masks that error.
This commit is contained in:
parent
a4912d4f00
commit
5d41e7a36e
1 changed files with 13 additions and 1 deletions
|
|
@ -426,7 +426,19 @@ async function loadSettings() {
|
|||
command('location,' + (s.startLineNumber-1) + ',' + (s.startColumn-1) + ',' + (s.endLineNumber-1) + ',' + (s.endColumn-1) + ',' + n);
|
||||
var token = getTokenAtCursor();
|
||||
if (token) {
|
||||
command('token,' + token.column + ',' + encodeURIComponent(token.text));
|
||||
let text;
|
||||
try {
|
||||
text = encodeURIComponent(token.text);
|
||||
} catch(e) {
|
||||
if(e instanceof URIError) {
|
||||
// if token.text contains an unpaired surrogate, encodeURIComponent
|
||||
// fails with a URIError, in which case we will just avoid
|
||||
// sending the token command.
|
||||
return;
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
command('token,' + token.column + ',' + text);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue