@@ -57,19 +57,6 @@ export interface ITextAreaInputHost {
5757 deduceModelPosition ( viewAnchorPosition : Position , deltaOffset : number , lineFeedCnt : number ) : Position ;
5858}
5959
60- const enum TextAreaInputEventType {
61- none ,
62- compositionstart ,
63- compositionupdate ,
64- compositionend ,
65- input ,
66- cut ,
67- copy ,
68- paste ,
69- focus ,
70- blur
71- }
72-
7360interface CompositionEvent extends UIEvent {
7461 readonly data : string ;
7562 readonly locale : string ;
@@ -155,7 +142,6 @@ export class TextAreaInput extends Disposable {
155142
156143 private readonly _host : ITextAreaInputHost ;
157144 private readonly _textArea : TextAreaWrapper ;
158- private _lastTextAreaEvent : TextAreaInputEventType ;
159145 private readonly _asyncTriggerCut : RunOnceScheduler ;
160146
161147 private _textAreaState : TextAreaState ;
@@ -169,7 +155,6 @@ export class TextAreaInput extends Disposable {
169155 super ( ) ;
170156 this . _host = host ;
171157 this . _textArea = this . _register ( new TextAreaWrapper ( textArea ) ) ;
172- this . _lastTextAreaEvent = TextAreaInputEventType . none ;
173158 this . _asyncTriggerCut = this . _register ( new RunOnceScheduler ( ( ) => this . _onCut . fire ( ) , 0 ) ) ;
174159
175160 this . _textAreaState = TextAreaState . EMPTY ;
@@ -200,8 +185,6 @@ export class TextAreaInput extends Disposable {
200185 } ) ) ;
201186
202187 this . _register ( dom . addDisposableListener ( textArea . domNode , 'compositionstart' , ( e : CompositionEvent ) => {
203- this . _lastTextAreaEvent = TextAreaInputEventType . compositionstart ;
204-
205188 if ( this . _isDoingComposition ) {
206189 return ;
207190 }
@@ -218,10 +201,10 @@ export class TextAreaInput extends Disposable {
218201 /**
219202 * Deduce the typed input from a text area's value and the last observed state.
220203 */
221- const deduceInputFromTextAreaValue = ( couldBeEmojiInput : boolean , couldBeTypingAtOffset0 : boolean ) : [ TextAreaState , ITypeData ] => {
204+ const deduceInputFromTextAreaValue = ( couldBeEmojiInput : boolean ) : [ TextAreaState , ITypeData ] => {
222205 const oldState = this . _textAreaState ;
223206 const newState = TextAreaState . readFromTextArea ( this . _textArea ) ;
224- return [ newState , TextAreaState . deduceInput ( oldState , newState , couldBeEmojiInput , couldBeTypingAtOffset0 ) ] ;
207+ return [ newState , TextAreaState . deduceInput ( oldState , newState , couldBeEmojiInput ) ] ;
225208 } ;
226209
227210 /**
@@ -258,10 +241,8 @@ export class TextAreaInput extends Disposable {
258241 } ;
259242
260243 this . _register ( dom . addDisposableListener ( textArea . domNode , 'compositionupdate' , ( e : CompositionEvent ) => {
261- this . _lastTextAreaEvent = TextAreaInputEventType . compositionupdate ;
262-
263244 if ( compositionDataInValid ( e . locale ) ) {
264- const [ newState , typeInput ] = deduceInputFromTextAreaValue ( /*couldBeEmojiInput*/ false , /*couldBeTypingAtOffset0*/ false ) ;
245+ const [ newState , typeInput ] = deduceInputFromTextAreaValue ( /*couldBeEmojiInput*/ false ) ;
265246 this . _textAreaState = newState ;
266247 this . _onType . fire ( typeInput ) ;
267248 this . _onCompositionUpdate . fire ( e ) ;
@@ -275,15 +256,14 @@ export class TextAreaInput extends Disposable {
275256 } ) ) ;
276257
277258 this . _register ( dom . addDisposableListener ( textArea . domNode , 'compositionend' , ( e : CompositionEvent ) => {
278- this . _lastTextAreaEvent = TextAreaInputEventType . compositionend ;
279259 // https://github.com/microsoft/monaco-editor/issues/1663
280260 // On iOS 13.2, Chinese system IME randomly trigger an additional compositionend event with empty data
281261 if ( ! this . _isDoingComposition ) {
282262 return ;
283263 }
284264 if ( compositionDataInValid ( e . locale ) ) {
285265 // https://github.com/Microsoft/monaco-editor/issues/339
286- const [ newState , typeInput ] = deduceInputFromTextAreaValue ( /*couldBeEmojiInput*/ false , /*couldBeTypingAtOffset0*/ false ) ;
266+ const [ newState , typeInput ] = deduceInputFromTextAreaValue ( /*couldBeEmojiInput*/ false ) ;
287267 this . _textAreaState = newState ;
288268 this . _onType . fire ( typeInput ) ;
289269 } else {
@@ -307,10 +287,6 @@ export class TextAreaInput extends Disposable {
307287 } ) ) ;
308288
309289 this . _register ( dom . addDisposableListener ( textArea . domNode , 'input' , ( ) => {
310- // We want to find out if this is the first `input` after a `focus`.
311- const previousEventWasFocus = ( this . _lastTextAreaEvent === TextAreaInputEventType . focus ) ;
312- this . _lastTextAreaEvent = TextAreaInputEventType . input ;
313-
314290 // Pretend here we touched the text area, as the `input` event will most likely
315291 // result in a `selectionchange` event which we want to ignore
316292 this . _textArea . setIgnoreSelectionChangeTime ( 'received input event' ) ;
@@ -319,7 +295,7 @@ export class TextAreaInput extends Disposable {
319295 return ;
320296 }
321297
322- const [ newState , typeInput ] = deduceInputFromTextAreaValue ( /*couldBeEmojiInput*/ platform . isMacintosh , /*couldBeTypingAtOffset0*/ previousEventWasFocus && platform . isMacintosh ) ;
298+ const [ newState , typeInput ] = deduceInputFromTextAreaValue ( /*couldBeEmojiInput*/ platform . isMacintosh ) ;
323299 if ( typeInput . replaceCharCnt === 0 && typeInput . text . length === 1 && strings . isHighSurrogate ( typeInput . text . charCodeAt ( 0 ) ) ) {
324300 // Ignore invalid input but keep it around for next time
325301 return ;
@@ -341,8 +317,6 @@ export class TextAreaInput extends Disposable {
341317 // --- Clipboard operations
342318
343319 this . _register ( dom . addDisposableListener ( textArea . domNode , 'cut' , ( e : ClipboardEvent ) => {
344- this . _lastTextAreaEvent = TextAreaInputEventType . cut ;
345-
346320 // Pretend here we touched the text area, as the `cut` event will most likely
347321 // result in a `selectionchange` event which we want to ignore
348322 this . _textArea . setIgnoreSelectionChangeTime ( 'received cut event' ) ;
@@ -352,14 +326,10 @@ export class TextAreaInput extends Disposable {
352326 } ) ) ;
353327
354328 this . _register ( dom . addDisposableListener ( textArea . domNode , 'copy' , ( e : ClipboardEvent ) => {
355- this . _lastTextAreaEvent = TextAreaInputEventType . copy ;
356-
357329 this . _ensureClipboardGetsEditorSelection ( e ) ;
358330 } ) ) ;
359331
360332 this . _register ( dom . addDisposableListener ( textArea . domNode , 'paste' , ( e : ClipboardEvent ) => {
361- this . _lastTextAreaEvent = TextAreaInputEventType . paste ;
362-
363333 // Pretend here we touched the text area, as the `paste` event will most likely
364334 // result in a `selectionchange` event which we want to ignore
365335 this . _textArea . setIgnoreSelectionChangeTime ( 'received paste event' ) ;
@@ -379,11 +349,9 @@ export class TextAreaInput extends Disposable {
379349 } ) ) ;
380350
381351 this . _register ( dom . addDisposableListener ( textArea . domNode , 'focus' , ( ) => {
382- this . _lastTextAreaEvent = TextAreaInputEventType . focus ;
383352 this . _setHasFocus ( true ) ;
384353 } ) ) ;
385354 this . _register ( dom . addDisposableListener ( textArea . domNode , 'blur' , ( ) => {
386- this . _lastTextAreaEvent = TextAreaInputEventType . blur ;
387355 this . _setHasFocus ( false ) ;
388356 } ) ) ;
389357 }
0 commit comments