Skip to content

Commit 72860a0

Browse files
committed
Improve positioning of native IME popup
1 parent 2c90237 commit 72860a0

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/vs/editor/browser/controller/textAreaHandler.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,8 @@ export class TextAreaHandler extends ViewPart {
592592
// In case the textarea contains a word, we're going to try to align the textarea's cursor
593593
// with our cursor by scrolling the textarea as much as possible
594594
this.textArea.domNode.scrollLeft = this._primaryCursorVisibleRange.left;
595+
const lineCount = this._newlinecount(this.textArea.domNode.value.substr(0, this.textArea.domNode.selectionStart));
596+
this.textArea.domNode.scrollTop = lineCount * this._lineHeight;
595597
return;
596598
}
597599

@@ -602,6 +604,19 @@ export class TextAreaHandler extends ViewPart {
602604
);
603605
}
604606

607+
private _newlinecount(text: string): number {
608+
let result = 0;
609+
let startIndex = -1;
610+
do {
611+
startIndex = text.indexOf('\n', startIndex + 1);
612+
if (startIndex === -1) {
613+
break;
614+
}
615+
result++;
616+
} while (true);
617+
return result;
618+
}
619+
605620
private _renderInsideEditor(renderedPosition: Position | null, top: number, left: number, width: number, height: number): void {
606621
this._lastRenderPosition = renderedPosition;
607622
const ta = this.textArea;

0 commit comments

Comments
 (0)