diff --git a/src/vs/editor/browser/controller/editContext/textArea/textAreaEditContext.ts b/src/vs/editor/browser/controller/editContext/textArea/textAreaEditContext.ts index 1afbfb12b855a8..6d1ab16559b75f 100644 --- a/src/vs/editor/browser/controller/editContext/textArea/textAreaEditContext.ts +++ b/src/vs/editor/browser/controller/editContext/textArea/textAreaEditContext.ts @@ -207,8 +207,8 @@ export class TextAreaEditContext extends AbstractEditContext { const textAreaInputHost: ITextAreaInputHost = { context: this._context, getScreenReaderContent: (): TextAreaState => { - if (this._accessibilitySupport === AccessibilitySupport.Disabled) { - // We know for a fact that a screen reader is not attached + if (this._accessibilitySupport === AccessibilitySupport.Disabled || (this._accessibilitySupport === AccessibilitySupport.Unknown && !browser.isAndroid)) { + // No screen reader is known to be attached; a page here gives WebKit an overflow to scroll during IME composition (monaco-editor#4796) // On OSX, we write the character before the cursor to allow for "long-press" composition // Also on OSX, we write the word before the cursor to allow for the Accessibility Keyboard to give good hints const selection = this._selections[0]; @@ -559,13 +559,13 @@ export class TextAreaEditContext extends AbstractEditContext { this._accessibilityPageSize = accessibilityPageSize; } - // When wrapping is enabled and a screen reader might be attached, + // When wrapping is enabled and a screen reader is attached, // we will size the textarea to match the width used for wrapping points computation (see `domLineBreaksComputer.ts`). // This is because screen readers will read the text in the textarea and we'd like that the // wrapping points in the textarea match the wrapping points in the editor. const layoutInfo = options.get(EditorOption.layoutInfo); const wrappingColumn = layoutInfo.wrappingColumn; - if (wrappingColumn !== -1 && this._accessibilitySupport !== AccessibilitySupport.Disabled) { + if (wrappingColumn !== -1 && this._accessibilitySupport === AccessibilitySupport.Enabled) { const fontInfo = options.get(EditorOption.fontInfo); this._textAreaWrapping = true; this._textAreaWidth = Math.round(wrappingColumn * fontInfo.typicalHalfwidthCharacterWidth); @@ -748,9 +748,6 @@ export class TextAreaEditContext extends AbstractEditContext { (textareaSpansSingleToken ? viewLineData.tokens.getPresentation(startTokenIndex) : null) ); - this.textArea.domNode.scrollTop = lineCount * lineHeight; - this.textArea.domNode.scrollLeft = scrollLeft; - this._doRender({ lastRenderPosition: null, top: top, @@ -765,6 +762,9 @@ export class TextAreaEditContext extends AbstractEditContext { strikethrough: presentation.strikethrough, fontSize }); + // After `_doRender`, as the branch below does: the offsets are clamped against the size it just set + this.textArea.domNode.scrollTop = lineCount * lineHeight; + this.textArea.domNode.scrollLeft = scrollLeft; } return; }