mirror of
https://github.com/keymanapp/keyman.git
synced 2026-09-21 15:17:40 +00:00
fix(web): prevents selection-clear for pure layer-switching multitaps
This commit is contained in:
parent
6a2b9015c5
commit
0c8f520e2a
2 changed files with 25 additions and 2 deletions
|
|
@ -107,8 +107,20 @@ export default class InputProcessor {
|
|||
if(keyEvent.baseTranscriptionToken) {
|
||||
const transcription = this.contextCache.get(keyEvent.baseTranscriptionToken);
|
||||
if(transcription) {
|
||||
// Restores full context, including deadkeys in their exact pre-keystroke state.
|
||||
outputTarget.restoreTo(transcription.preInput);
|
||||
// Has there been a context change at any point during the multitap? If so, we need
|
||||
// to revert it. If not, we assume it's a layer-change multitap, in which case
|
||||
// no such reset is needed.
|
||||
if(!isEmptyTransform(transcription.transform) || !transcription.preInput.isEqual(Mock.from(outputTarget))) {
|
||||
// Restores full context, including deadkeys in their exact pre-keystroke state.
|
||||
outputTarget.restoreTo(transcription.preInput);
|
||||
}
|
||||
/*
|
||||
else:
|
||||
1. We don't need to restore the original context, as it's already
|
||||
in-place.
|
||||
2. Restoring anyway would obliterate any selected text, which is bad
|
||||
if this is a purely-layer-switching multitap. (#11230)
|
||||
*/
|
||||
} else {
|
||||
console.warn('The base context for the multitap could not be found');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -446,6 +446,17 @@ export class Mock extends OutputTarget {
|
|||
this.text = this.getTextBeforeCaret() + s;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if this Mock represents an identical context to that of another Mock.
|
||||
*
|
||||
* Does not currently validate a match for deadkeys.
|
||||
* @param other
|
||||
* @returns
|
||||
*/
|
||||
isEqual(other: Mock) {
|
||||
return this.text == other.text && this.selStart == other.selStart && this.selEnd == other.selEnd;
|
||||
}
|
||||
|
||||
doInputEvent() {
|
||||
// Mock isn't backed by an element, so it won't have any event listeners.
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue