From 2f264075926b8c41cd4a7e63809a7165b14c7633 Mon Sep 17 00:00:00 2001 From: Joe Cheng Date: Fri, 11 Feb 2011 07:42:30 +0800 Subject: [PATCH] Fix bug where typing or pasting to extend the longest line causes the cursor and last character to be hidden --- lib/ace/virtual_renderer.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/ace/virtual_renderer.js b/lib/ace/virtual_renderer.js index 6b94b43b..28154f15 100644 --- a/lib/ace/virtual_renderer.js +++ b/lib/ace/virtual_renderer.js @@ -84,6 +84,7 @@ var VirtualRenderer = function(container, theme) { this.lineHeight = textLayer.getLineHeight(); this.$cursorLayer = new CursorLayer(this.content); + this.$cursorPadding = 8; this.layers = [ this.$markerLayer, textLayer, this.$cursorLayer ]; @@ -424,7 +425,8 @@ var VirtualRenderer = function(container, theme) { var offset = this.scrollTop % this.lineHeight; var minHeight = this.$size.scrollerHeight + this.lineHeight; - var longestLine = this.$getLongestLine(); + // Add some space for the cursor itself plus some cursor padding + var longestLine = this.$getLongestLine() + this.$cursorPadding + 3; var widthChanged = !this.layerConfig ? true : (this.layerConfig.width != longestLine); var lineCount = Math.ceil(minHeight / this.lineHeight) - 1; @@ -560,8 +562,12 @@ var VirtualRenderer = function(container, theme) { } if (this.scroller.scrollLeft + this.$size.scrollerWidth < left - + this.characterWidth) { - this.scrollToX(Math.round(left + this.characterWidth + + this.characterWidth + this.$cursorPadding) { + + if (left + this.characterWidth + this.$cursorPadding > this.scroller.scrollWidth) + this.$renderChanges(this.CHANGE_SIZE); + + this.scrollToX(Math.round(left + this.characterWidth + this.$cursorPadding - this.$size.scrollerWidth)); } },