Skip to content

Commit 4067512

Browse files
committed
fix: add mock getHighlightIndentGuides and setHighlightIndentGuides for old tests to work
1 parent f1f6517 commit 4067512

File tree

2 files changed

+35
-28
lines changed

2 files changed

+35
-28
lines changed

src/layer/text.js

+29-28
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ var Lines = require("./lines").Lines;
77
var EventEmitter = require("../lib/event_emitter").EventEmitter;
88

99
var Text = function(parentEl) {
10-
this.dom = dom;
10+
this.dom = dom;
1111
this.element = this.dom.createElement("div");
1212
this.element.className = "ace_layer ace_text-layer";
1313
parentEl.appendChild(this.element);
@@ -50,7 +50,7 @@ var Text = function(parentEl) {
5050
this.getCharacterWidth = function() {
5151
return this.$fontMetrics.$characterSize.width || 0;
5252
};
53-
53+
5454
this.$setFontMetrics = function(measure) {
5555
this.$fontMetrics = measure;
5656
this.$fontMetrics.on("changeCharacterSize", function(e) {
@@ -135,15 +135,15 @@ var Text = function(parentEl) {
135135
: lang.stringRepeat(" ", this.tabSize);
136136

137137
var tabClass = this.showTabs ? " ace_invisible ace_invisible_tab" : "";
138-
var tabContent = this.showTabs
138+
var tabContent = this.showTabs
139139
? lang.stringRepeat(this.TAB_CHAR, this.tabSize)
140140
: spaceContent;
141141

142142
var span = this.dom.createElement("span");
143143
span.className = className + spaceClass;
144144
span.textContent = spaceContent;
145145
this.$tabStrings[" "] = span;
146-
146+
147147
var span = this.dom.createElement("span");
148148
span.className = className + tabClass;
149149
span.textContent = tabContent;
@@ -158,7 +158,7 @@ var Text = function(parentEl) {
158158
this.config.firstRow != config.firstRow) {
159159
return this.update(config);
160160
}
161-
161+
162162
this.config = config;
163163

164164
var first = Math.max(firstRow, config.firstRow);
@@ -226,9 +226,9 @@ var Text = function(parentEl) {
226226

227227
if (this.$lines.pageChanged(oldConfig, config))
228228
return this.update(config);
229-
229+
230230
this.$lines.moveContainer(config);
231-
231+
232232
var lastRow = config.lastRow;
233233
var oldLastRow = oldConfig ? oldConfig.lastRow : -1;
234234

@@ -278,7 +278,7 @@ var Text = function(parentEl) {
278278
break;
279279

280280
var line = this.$lines.createCell(row, config, this.session);
281-
281+
282282
var lineEl = line.element;
283283
this.dom.removeChildren(lineEl);
284284
dom.setStyle(lineEl.style, "height", this.$lines.computeLineHeight(row, config, this.session) + "px");
@@ -302,7 +302,7 @@ var Text = function(parentEl) {
302302

303303
this.update = function(config) {
304304
this.$lines.moveContainer(config);
305-
305+
306306
this.config = config;
307307

308308
var firstRow = config.firstRow;
@@ -311,7 +311,7 @@ var Text = function(parentEl) {
311311
var lines = this.$lines;
312312
while (lines.getLength())
313313
lines.pop();
314-
314+
315315
lines.push(this.$renderLinesFragment(config, firstRow, lastRow));
316316
};
317317

@@ -324,7 +324,7 @@ var Text = function(parentEl) {
324324
this.$renderToken = function(parent, screenColumn, token, value) {
325325
var self = this;
326326
var re = /(\t)|( +)|([\x00-\x1f\x80-\xa0\xad\u1680\u180E\u2000-\u200f\u2028\u2029\u202F\u205F\uFEFF\uFFF9-\uFFFC\u2066\u2067\u2068\u202A\u202B\u202D\u202E\u202C\u2069]+)|(\u3000)|([\u1100-\u115F\u11A3-\u11A7\u11FA-\u11FF\u2329-\u232A\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFB\u3001-\u303E\u3041-\u3096\u3099-\u30FF\u3105-\u312D\u3131-\u318E\u3190-\u31BA\u31C0-\u31E3\u31F0-\u321E\u3220-\u3247\u3250-\u32FE\u3300-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFAFF\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE66\uFE68-\uFE6B\uFF01-\uFF60\uFFE0-\uFFE6]|[\uD800-\uDBFF][\uDC00-\uDFFF])/g;
327-
327+
328328
var valueFragment = this.dom.createFragment(this.element);
329329

330330
var m;
@@ -335,18 +335,18 @@ var Text = function(parentEl) {
335335
var controlCharacter = m[3];
336336
var cjkSpace = m[4];
337337
var cjk = m[5];
338-
338+
339339
if (!self.showSpaces && simpleSpace)
340340
continue;
341341

342342
var before = i != m.index ? value.slice(i, m.index) : "";
343343

344344
i = m.index + m[0].length;
345-
345+
346346
if (before) {
347347
valueFragment.appendChild(this.dom.createTextNode(before, this.element));
348348
}
349-
349+
350350
if (tab) {
351351
var tabSize = self.session.getScreenTabSize(screenColumn + m.index);
352352
valueFragment.appendChild(self.$tabStrings[tabSize].cloneNode(true));
@@ -368,7 +368,7 @@ var Text = function(parentEl) {
368368
} else if (cjkSpace) {
369369
// U+3000 is both invisible AND full-width, so must be handled uniquely
370370
screenColumn += 1;
371-
371+
372372
var span = this.dom.createElement("span");
373373
span.style.width = (self.config.characterWidth * 2) + "px";
374374
span.className = self.showSpaces ? "ace_cjk ace_invisible ace_invisible_space" : "ace_cjk";
@@ -383,24 +383,24 @@ var Text = function(parentEl) {
383383
valueFragment.appendChild(span);
384384
}
385385
}
386-
386+
387387
valueFragment.appendChild(this.dom.createTextNode(i ? value.slice(i) : value, this.element));
388388

389389
if (!this.$textToken[token.type]) {
390390
var classes = "ace_" + token.type.replace(/\./g, " ace_");
391391
var span = this.dom.createElement("span");
392392
if (token.type == "fold")
393393
span.style.width = (token.value.length * this.config.characterWidth) + "px";
394-
394+
395395
span.className = classes;
396396
span.appendChild(valueFragment);
397-
397+
398398
parent.appendChild(span);
399399
}
400400
else {
401401
parent.appendChild(valueFragment);
402402
}
403-
403+
404404
return screenColumn + value.length;
405405
};
406406

@@ -504,9 +504,10 @@ var Text = function(parentEl) {
504504
"ace_indent-guide", "ace_indent-guide-active");
505505
}
506506
}
507-
}
507+
};
508508

509509
this.$renderHighlightIndentGuide = function () {
510+
if (!this.$lines) return;
510511
var cells = this.$lines.cells;
511512
this.$clearActiveIndentGuide();
512513
var indentLevel = this.$highlightIndentGuideMarker.indentLevel;
@@ -537,7 +538,7 @@ var Text = function(parentEl) {
537538
var lineEl = this.dom.createElement("div");
538539
lineEl.className = "ace_line";
539540
lineEl.style.height = this.config.lineHeight + "px";
540-
541+
541542
return lineEl;
542543
};
543544

@@ -549,7 +550,7 @@ var Text = function(parentEl) {
549550

550551
var lineEl = this.$createLineElement();
551552
parent.appendChild(lineEl);
552-
553+
553554
for (var i = 0; i < tokens.length; i++) {
554555
var token = tokens[i];
555556
var value = token.value;
@@ -590,7 +591,7 @@ var Text = function(parentEl) {
590591
}
591592
}
592593
}
593-
594+
594595
if (splits[splits.length - 1] > this.MAX_LINE_LENGTH)
595596
this.$renderOverflowMessage(lineEl, screenColumn, null, "", true);
596597
};
@@ -611,16 +612,16 @@ var Text = function(parentEl) {
611612
screenColumn = this.$renderToken(parent, screenColumn, token, value);
612613
}
613614
};
614-
615+
615616
this.$renderOverflowMessage = function(parent, screenColumn, token, value, hide) {
616617
token && this.$renderToken(parent, screenColumn, token,
617618
value.slice(0, this.MAX_LINE_LENGTH - screenColumn));
618-
619+
619620
var overflowEl = this.dom.createElement("span");
620621
overflowEl.className = "ace_inline_button ace_keyword ace_toggle_wrap";
621622
overflowEl.textContent = hide ? "<hide>" : "<click to see more...>";
622-
623-
parent.appendChild(overflowEl);
623+
624+
parent.appendChild(overflowEl);
624625
};
625626

626627
// row is either first row of foldline or not in fold
@@ -659,7 +660,7 @@ var Text = function(parentEl) {
659660
var invisibleEl = this.dom.createElement("span");
660661
invisibleEl.className = "ace_invisible ace_invisible_eol";
661662
invisibleEl.textContent = row == this.session.getLength() - 1 ? this.EOF_CHAR : this.EOL_CHAR;
662-
663+
663664
lastLineEl.appendChild(invisibleEl);
664665
}
665666
};

src/test/mockrenderer.js

+6
Original file line numberDiff line numberDiff line change
@@ -174,3 +174,9 @@ MockRenderer.prototype.screenToTextCoordinates = function() {
174174
MockRenderer.prototype.adjustWrapLimit = function () {
175175

176176
};
177+
178+
MockRenderer.prototype.getHighlightIndentGuides = function() {
179+
};
180+
181+
MockRenderer.prototype.setHighlightIndentGuides = function() {
182+
};

0 commit comments

Comments
 (0)