Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -737,11 +737,11 @@ export class TextAreaWrapper extends Disposable implements ICompleteTextAreaWrap
}

public getSelectionStart(): number {
return this._actual.selectionDirection === 'backward' ? this._actual.selectionEnd : this._actual.selectionStart;
return this._actual.selectionStart;

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is the correct fix for this input pipeline.

TextAreaState and the input diffing engine (deduceInput) assume standard, normalized selection boundaries (selectionStart <= selectionEnd). Standard browsers also do not support setting a selection range where selectionStart > selectionEnd (doing so collapses the selection).

Swapping selectionStart and selectionEnd for backward/RTL selections violates these assumptions, leading to a state mismatch where the native selection is collapsed and replacePrevCharCnt is incorrectly computed as 1 instead of 0 on the first keypress.

Since the hidden textarea is only used for IME/input bridging and not direct user selection interaction, returning normalized boundaries here is safe and correctly aligns the native state with TextAreaState expectations, solving the double-keypress bug without breaking caret logic.

}

public getSelectionEnd(): number {
return this._actual.selectionDirection === 'backward' ? this._actual.selectionStart : this._actual.selectionEnd;
return this._actual.selectionEnd;

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is the correct fix for this input pipeline.

TextAreaState and the input diffing engine (deduceInput) assume standard, normalized selection boundaries (selectionStart <= selectionEnd). Standard browsers also do not support setting a selection range where selectionStart > selectionEnd (doing so collapses the selection).

Swapping selectionStart and selectionEnd for backward/RTL selections violates these assumptions, leading to a state mismatch where the native selection is collapsed and replacePrevCharCnt is incorrectly computed as 1 instead of 0 on the first keypress.

Since the hidden textarea is only used for IME/input bridging and not direct user selection interaction, returning normalized boundaries here is safe and correctly aligns the native state with TextAreaState expectations, solving the double-keypress bug without breaking caret logic.

}

public setSelectionRange(reason: string, selectionStart: number, selectionEnd: number): void {
Expand Down