From 3fbfadde5a62ac2da18c3e8dd40fd616aba2469a Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Fri, 19 Jan 2018 11:20:53 +0100 Subject: [PATCH] Don't break subpixel AA when cursor is at the end of longest line With the Electron upgrade, something changed in the way characters are rendered/measured, and that was causing subpixel anti-aliasing to stop working when cursors were at the end of the longest line. Every cursor has a width that is calculated in the following way: * If there's a character after the cursor, the width corresponds to width of such character. * Otherwise, the width equals to the "base character width" measured on a dummy line. In the latter case, even if we were setting the width of the content container to account for the width of such cursor, some rounding problem was causing the cursor to be able to escape the container and thus break subpixel anti-aliasing. With this commit, instead of rounding the value we assign to the container width, we will always ceil it. This ensures that cursors are always strictly contained within the parent element and resolves the subpixel anti-aliasing issue. --- src/text-editor-component.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/text-editor-component.js b/src/text-editor-component.js index 855920b3b..c88aab304 100644 --- a/src/text-editor-component.js +++ b/src/text-editor-component.js @@ -2694,7 +2694,7 @@ class TextEditorComponent { } getContentWidth () { - return Math.round(this.getLongestLineWidth() + this.getBaseCharacterWidth()) + return Math.ceil(this.getLongestLineWidth() + this.getBaseCharacterWidth()) } getScrollContainerClientWidthInBaseCharacters () {