Skip to content

Commit

Permalink
Merge pull request #3998 from ajaxorg/fix-wrapped-line-update
Browse files Browse the repository at this point in the history
fix wrapped line rendering
  • Loading branch information
nightwing committed Jun 28, 2019
2 parents a57f6b9 + bf06768 commit 7285dad
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/ace/layer/text.js
Expand Up @@ -215,6 +215,10 @@ var Text = function(parentEl) {
this.$renderLine(
lineElement, row, row == foldStart ? foldLine : false
);

if (heightChanged)
lineElement.style.top = this.$lines.computeLineTop(row, config, this.session) + "px";

var height = (config.lineHeight * this.session.getRowLength(row)) + "px";
if (lineElement.style.height != height) {
heightChanged = true;
Expand Down
3 changes: 3 additions & 0 deletions lib/ace/virtual_renderer.js
Expand Up @@ -887,6 +887,7 @@ var VirtualRenderer = function(container, theme) {

// full
if (changes & this.CHANGE_FULL) {
this.$changedLines = null;
this.$textLayer.update(config);
if (this.$showGutter)
this.$gutterLayer.update(config);
Expand All @@ -900,6 +901,7 @@ var VirtualRenderer = function(container, theme) {

// scrolling
if (changes & this.CHANGE_SCROLL) {
this.$changedLines = null;
if (changes & this.CHANGE_TEXT || changes & this.CHANGE_LINES)
this.$textLayer.update(config);
else
Expand All @@ -920,6 +922,7 @@ var VirtualRenderer = function(container, theme) {
}

if (changes & this.CHANGE_TEXT) {
this.$changedLines = null;
this.$textLayer.update(config);
if (this.$showGutter)
this.$gutterLayer.update(config);
Expand Down
17 changes: 17 additions & 0 deletions lib/ace/virtual_renderer_test.js
Expand Up @@ -36,6 +36,7 @@ if (typeof process !== "undefined") {
define(function(require, exports, module) {
"use strict";

var Range = require("./range").Range;
var Editor = require("./editor").Editor;
var EditSession = require("./edit_session").EditSession;
var VirtualRenderer = require("./virtual_renderer").VirtualRenderer;
Expand Down Expand Up @@ -183,6 +184,22 @@ module.exports = {
assert.ok(editor.session.lineWidgets[1]);
},

"test wrapped text rendering": function() {
editor.setValue("a".repeat(452) + "\n" + "b".repeat(100) + "\nxxxxxx", -1);
editor.container.style.height = "500px";
editor.setOption("wrap", 40);
editor.resize(true);
editor.renderer.$loop._flush();

assert.equal(editor.renderer.$changedLines, null);
editor.session.remove(new Range(0, 10, 0, 350));
editor.session.insert({row: 1, column: 1}, "l".repeat(350));
editor.renderer.$loop._flush();
var lines = editor.renderer.$textLayer.element.children;
assert.notEqual(lines[0].style.height, lines[1].style.height);
assert.equal(lines[0].style.height, lines[1].style.top);
},

"test resize": function() {
editor.setValue("Juhu kinners!");
editor.resize(true);
Expand Down

0 comments on commit 7285dad

Please sign in to comment.