diff --git a/src/autocomplete/inline_test.js b/src/autocomplete/inline_test.js index 3fd48d42d5b..edffcf76e74 100644 --- a/src/autocomplete/inline_test.js +++ b/src/autocomplete/inline_test.js @@ -101,8 +101,7 @@ module.exports = { inline.show(editor, completions[3], "f"); editor.renderer.$loop._flush(); assert.strictEqual(getAllLines(), textBase + "function foo() {"); - assert.strictEqual(editor.renderer.$ghostTextWidget.html, "
console.log('test');
}
"); - assert.strictEqual(editor.renderer.$ghostTextWidget.el.innerHTML, "
console.log('test');
}
"); + assert.strictEqual(editor.renderer.$ghostTextWidget.el.innerHTML, `
console.log('test');
}
`); done(); }, "test: boundary tests": function(done) { diff --git a/src/ext/inline_autocomplete_test.js b/src/ext/inline_autocomplete_test.js index af98a6e81e6..6c6611d6f0c 100644 --- a/src/ext/inline_autocomplete_test.js +++ b/src/ext/inline_autocomplete_test.js @@ -30,7 +30,7 @@ var getAllLines = function() { return node.textContent; }).join("\n"); if (editor.renderer.$ghostTextWidget) { - return text + "\n" + editor.renderer.$ghostTextWidget.html; + return text + "\n" + editor.renderer.$ghostTextWidget.el.innerHTML; } return text; }; @@ -358,7 +358,7 @@ module.exports = { typeAndChange("u", "n"); editor.renderer.$loop._flush(); assert.strictEqual(autocomplete.isOpen(), true); - assert.equal(getAllLines(), "function foo() {\n
console.log('test');
}
"); + assert.equal(getAllLines(), `function foo() {\n
console.log('test');
}
`); typeAndChange("d"); editor.renderer.$loop._flush(); diff --git a/src/mouse/default_gutter_handler.js b/src/mouse/default_gutter_handler.js index 3d705eca22b..7cc984efe95 100644 --- a/src/mouse/default_gutter_handler.js +++ b/src/mouse/default_gutter_handler.js @@ -219,13 +219,32 @@ class GutterTooltip extends Tooltip { // Construct the contents of the tooltip. for (let i = 0; i < annotation.text.length; i++) { - var line = ` ${annotation.text[i]}`; - annotationMessages[annotation.type[i].replace("_fold","")].push(line); + var lineElement = dom.createElement("span"); + + var iconElement = dom.createElement("span"); + iconElement.classList.add(...[`ace_${annotation.type[i]}`, iconClassName]); + iconElement.setAttribute("aria-label", `${GutterTooltip.annotationLabels[annotation.type[i].replace("_fold","")].singular}`); + iconElement.setAttribute("role", "img"); + // Set empty content to the img span to get it to show up + iconElement.appendChild(dom.createTextNode(" ")); + + lineElement.appendChild(iconElement); + lineElement.appendChild(dom.createTextNode(`${annotation.text[i]}`)); + lineElement.appendChild(dom.createElement("br")); + + annotationMessages[annotation.type[i].replace("_fold","")].push(lineElement); } - var tooltipContent = [].concat(annotationMessages.error, annotationMessages.warning, annotationMessages.info).join("
"); - - this.setHtml(tooltipContent); - this.$element.setAttribute("aria-live", "polite"); + + // Clear the current tooltip content + var tooltipElement = this.getElement(); + dom.removeChildren(tooltipElement); + + // Update the tooltip content + annotationMessages.error.forEach(el => tooltipElement.appendChild(el)); + annotationMessages.warning.forEach(el => tooltipElement.appendChild(el)); + annotationMessages.info.forEach(el => tooltipElement.appendChild(el)); + + tooltipElement.setAttribute("aria-live", "polite"); if (!this.isOpen) { this.setTheme(this.editor.renderer.theme); diff --git a/src/virtual_renderer.js b/src/virtual_renderer.js index 40d5a927cd6..61796f29401 100644 --- a/src/virtual_renderer.js +++ b/src/virtual_renderer.js @@ -1776,13 +1776,21 @@ class VirtualRenderer { column: insertPosition. column } }; + + var widgetDiv = dom.createElement("div"); if (textChunks.length > 1) { - var divs = textChunks.slice(1).map(el => { - return `${el.text}`; + textChunks.slice(1).forEach(el => { + var chunkDiv = dom.createElement("div"); + + // If the line is wider than the viewport, wrap the line + if (el.wrapped) chunkDiv.className = "ghost_text_line_wrapped"; + + chunkDiv.appendChild(dom.createTextNode(el.text)); + widgetDiv.appendChild(chunkDiv); }); this.$ghostTextWidget = { - html: divs.join(""), + el: widgetDiv, row: insertPosition.row, column: insertPosition.column, className: "ace_ghost_text" diff --git a/src/virtual_renderer_test.js b/src/virtual_renderer_test.js index db94fb3d30b..03fda2cfb69 100644 --- a/src/virtual_renderer_test.js +++ b/src/virtual_renderer_test.js @@ -376,7 +376,7 @@ module.exports = { editor.renderer.$loop._flush(); assert.equal(editor.renderer.content.textContent, "abcdefGhost1"); - assert.equal(editor.session.lineWidgets[0].el.innerHTML, "
Ghost2
Ghost3
"); + assert.equal(editor.session.lineWidgets[0].el.innerHTML, `
Ghost2
Ghost3
`); editor.removeGhostText(); @@ -395,7 +395,7 @@ module.exports = { editor.renderer.$loop._flush(); assert.equal(editor.renderer.content.textContent, "abcdefThis is a long test text that is longer than "); - assert.equal(editor.session.lineWidgets[0].el.innerHTML, "
30 characters
Ghost3
"); + assert.equal(editor.session.lineWidgets[0].el.innerHTML, `
30 characters
Ghost3
`); editor.removeGhostText();