@xterm/xterm 6.1.0-beta.189 → 6.1.0-beta.190
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/xterm.js +1 -1
- package/lib/xterm.js.map +1 -1
- package/lib/xterm.mjs +2 -2
- package/lib/xterm.mjs.map +3 -3
- package/package.json +2 -2
- package/src/browser/input/CompositionHelper.ts +25 -6
- package/src/common/Version.ts +1 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xterm/xterm",
|
|
3
3
|
"description": "Full xterm terminal, in your browser",
|
|
4
|
-
"version": "6.1.0-beta.
|
|
4
|
+
"version": "6.1.0-beta.190",
|
|
5
5
|
"main": "lib/xterm.js",
|
|
6
6
|
"module": "lib/xterm.mjs",
|
|
7
7
|
"style": "css/xterm.css",
|
|
@@ -119,5 +119,5 @@
|
|
|
119
119
|
"ws": "^8.2.3",
|
|
120
120
|
"xterm-benchmark": "^0.3.1"
|
|
121
121
|
},
|
|
122
|
-
"commit": "
|
|
122
|
+
"commit": "26ce9bd4d396d9b86bbab8827cfae8378182fc0f"
|
|
123
123
|
}
|
|
@@ -30,6 +30,12 @@ export class CompositionHelper {
|
|
|
30
30
|
*/
|
|
31
31
|
private _compositionPosition: IPosition;
|
|
32
32
|
|
|
33
|
+
/**
|
|
34
|
+
* Text that existed after the composing range when composition started.
|
|
35
|
+
* This is used to avoid treating existing trailing text as new input.
|
|
36
|
+
*/
|
|
37
|
+
private _compositionSuffix: string;
|
|
38
|
+
|
|
33
39
|
/**
|
|
34
40
|
* Whether a composition is in the process of being sent, setting this to false will cancel any
|
|
35
41
|
* in-progress composition.
|
|
@@ -57,6 +63,7 @@ export class CompositionHelper {
|
|
|
57
63
|
this._isComposing = false;
|
|
58
64
|
this._isSendingComposition = false;
|
|
59
65
|
this._compositionPosition = { start: 0, end: 0 };
|
|
66
|
+
this._compositionSuffix = '';
|
|
60
67
|
this._dataAlreadySent = '';
|
|
61
68
|
}
|
|
62
69
|
|
|
@@ -65,7 +72,13 @@ export class CompositionHelper {
|
|
|
65
72
|
*/
|
|
66
73
|
public compositionstart(): void {
|
|
67
74
|
this._isComposing = true;
|
|
68
|
-
|
|
75
|
+
// It's important to use the selection here instead of textarea length to avoid conflicts with
|
|
76
|
+
// screen reader mode
|
|
77
|
+
const start = this._textarea.selectionStart ?? this._textarea.value.length;
|
|
78
|
+
const end = this._textarea.selectionEnd ?? start;
|
|
79
|
+
this._compositionPosition.start = Math.min(start, end);
|
|
80
|
+
this._compositionPosition.end = Math.max(start, end);
|
|
81
|
+
this._compositionSuffix = this._textarea.value.substring(this._compositionPosition.end);
|
|
69
82
|
this._compositionView.textContent = '';
|
|
70
83
|
this._dataAlreadySent = '';
|
|
71
84
|
this._compositionView.classList.add('active');
|
|
@@ -81,7 +94,8 @@ export class CompositionHelper {
|
|
|
81
94
|
this._compositionView.textContent = `\u200E${ev.data}\u200E`;
|
|
82
95
|
this.updateCompositionElements();
|
|
83
96
|
setTimeout(() => {
|
|
84
|
-
this.
|
|
97
|
+
const end = this._textarea.selectionEnd ?? this._textarea.value.length;
|
|
98
|
+
this._compositionPosition.end = Math.max( this._compositionPosition.start, end);
|
|
85
99
|
}, 0);
|
|
86
100
|
}
|
|
87
101
|
|
|
@@ -148,6 +162,7 @@ export class CompositionHelper {
|
|
|
148
162
|
start: this._compositionPosition.start,
|
|
149
163
|
end: this._compositionPosition.end
|
|
150
164
|
};
|
|
165
|
+
const currentCompositionSuffix = this._compositionSuffix;
|
|
151
166
|
|
|
152
167
|
// Since composition* events happen before the changes take place in the textarea on most
|
|
153
168
|
// browsers, use a setTimeout with 0ms time to allow the native compositionend event to
|
|
@@ -171,10 +186,14 @@ export class CompositionHelper {
|
|
|
171
186
|
// if a new composition has started.
|
|
172
187
|
input = this._textarea.value.substring(currentCompositionPosition.start, this._compositionPosition.start);
|
|
173
188
|
} else {
|
|
174
|
-
//
|
|
175
|
-
//
|
|
176
|
-
//
|
|
177
|
-
|
|
189
|
+
// Keep support for non-composition characters typed immediately after composition end
|
|
190
|
+
// while avoiding re-sending the trailing text that was already present
|
|
191
|
+
// before composition started.
|
|
192
|
+
const value = this._textarea.value;
|
|
193
|
+
const valueEnd = currentCompositionSuffix.length > 0 && value.endsWith(currentCompositionSuffix)
|
|
194
|
+
? value.length - currentCompositionSuffix.length
|
|
195
|
+
: value.length;
|
|
196
|
+
input = value.substring(currentCompositionPosition.start, Math.max(currentCompositionPosition.start, valueEnd));
|
|
178
197
|
}
|
|
179
198
|
if (input.length > 0) {
|
|
180
199
|
this._coreService.triggerDataEvent(input, true);
|
package/src/common/Version.ts
CHANGED