Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: highlight indent guides with wrapped lines #5621

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions src/layer/text.js
Original file line number Diff line number Diff line change
Expand Up @@ -511,25 +511,25 @@
}

$clearActiveIndentGuide() {
var cells = this.$lines.cells;
for (var i = 0; i < cells.length; i++) {
var cell = cells[i];
var childNodes = cell.element.childNodes;
if (childNodes.length > 0) {
for (var j = 0; j < childNodes.length; j++) {
if (childNodes[j].classList && childNodes[j].classList.contains("ace_indent-guide-active")) {
childNodes[j].classList.remove("ace_indent-guide-active");
break;
}
}
}
}
var activeIndentGuides = this.element.querySelectorAll(".ace_indent-guide-active");
activeIndentGuides.forEach(el => {
el.classList.remove("ace_indent-guide-active");
});
}

$setIndentGuideActive(cell, indentLevel) {
var line = this.session.doc.getLine(cell.row);
if (line !== "") {
var childNodes = cell.element.childNodes;
let element = cell.element;
if (cell.element.classList && cell.element.classList.contains("ace_line_group")) {
if (cell.element.childNodes.length > 0) {
element = cell.element.childNodes[0];
}
else {
return;

Check warning on line 529 in src/layer/text.js

View check run for this annotation

Codecov / codecov/patch

src/layer/text.js#L529

Added line #L529 was not covered by tests
}
}
var childNodes = element.childNodes;
if (childNodes) {
let node = childNodes[indentLevel - 1];
if (node && node.classList && node.classList.contains("ace_indent-guide")) node.classList.add(
Expand Down
1 change: 1 addition & 0 deletions src/virtual_renderer_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ module.exports = {
editor.session.setValue(
"function Test() {\n" + " function Inner() {\n" + " \n" + " \n" + " }\n" + "}");
editor.setOption("highlightIndentGuides", false);
editor.setOption("wrap", 10); // to make sure higlight works with wrapped lines
editor.session.selection.$setSelection(1, 22, 1, 22);
editor.resize(true);

Expand Down
Loading