Skip to content
3 changes: 1 addition & 2 deletions ace-internal.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,6 @@ export namespace Ace {
dragDelay: number;
dragEnabled: boolean;
focusTimeout: number;
tooltipFollowsMouse: boolean;
}

interface EditorOptions extends EditSessionOptions,
Expand Down Expand Up @@ -1629,7 +1628,6 @@ declare module "./src/mouse/mouse_event" {
declare module "./src/mouse/mouse_handler" {

export interface MouseHandler {
$tooltipFollowsMouse?: boolean,
cancelDrag?: boolean
//from DefaultHandlers
$clickSelection?: Ace.Range,
Expand All @@ -1638,6 +1636,7 @@ declare module "./src/mouse/mouse_handler" {
select?: () => void
$lastScroll?: { t: number, vx: number, vy: number, allowed: number }
selectEnd?: () => void
tooltip?: Ace.GutterTooltip
}
}

Expand Down
1 change: 0 additions & 1 deletion ace.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,6 @@ declare module "ace-code" {
dragDelay: number;
dragEnabled: boolean;
focusTimeout: number;
tooltipFollowsMouse: boolean;
}
interface EditorOptions extends EditSessionOptions, MouseHandlerOptions, VirtualRendererOptions {
selectionStyle: "fullLine" | "screenLine" | "text" | "line";
Expand Down
1 change: 0 additions & 1 deletion src/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -3121,7 +3121,6 @@ config.defineOptions(Editor.prototype, "editor", {
dragDelay: "$mouseHandler",
dragEnabled: "$mouseHandler",
focusTimeout: "$mouseHandler",
tooltipFollowsMouse: "$mouseHandler",

firstLineNumber: "session",
overwrite: "session",
Expand Down
1 change: 1 addition & 0 deletions src/editor_options_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ module.exports = {
assert.ok(editor.hoverTooltip != null);

var nodes = document.querySelectorAll(".ace_tooltip");
// TODO
assert.equal(nodes.length, 2);
assert.equal(editor.hoverTooltip.isOpen, true);

Expand Down
4 changes: 0 additions & 4 deletions src/ext/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,6 @@ var optionGroups = {
},
"Keyboard Accessibility Mode": {
path: "enableKeyboardAccessibility"
},
"Gutter tooltip follows mouse": {
path: "tooltipFollowsMouse",
defaultValue: true
}
}
};
Expand Down
12 changes: 4 additions & 8 deletions src/keyboard/gutter_handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class GutterKeyboardHandler {
e.preventDefault();

if (e.keyCode === keys["escape"])
this.annotationTooltip.hideTooltip();
this.annotationTooltip.hide();

return;
}
Expand Down Expand Up @@ -186,12 +186,8 @@ class GutterKeyboardHandler {
return;

case "annotation":
var gutterElement = this.lines.cells[this.activeRowIndex].element.childNodes[2];
var rect = gutterElement.getBoundingClientRect();
var style = this.annotationTooltip.getElement().style;
style.left = rect.right + "px";
style.top = rect.bottom + "px";
this.annotationTooltip.showTooltip(this.$rowIndexToRow(this.activeRowIndex));
this.annotationTooltip.showTooltip(this.$rowIndexToRow(this.activeRowIndex));
window.removeEventListener("keydown", this.annotationTooltip.hide, true);
break;
}
return;
Expand All @@ -213,7 +209,7 @@ class GutterKeyboardHandler {
}

if (this.annotationTooltip.isOpen)
this.annotationTooltip.hideTooltip();
this.annotationTooltip.hide();

return;
}
Expand Down
22 changes: 16 additions & 6 deletions src/keyboard/gutter_handler_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@ function emit(keyCode) {
el.dispatchEvent(event);
}

function findVisibleTooltip() {
const tooltips = document.body.querySelectorAll(".ace_gutter-tooltip");
for (let i = 0; i < tooltips.length; i++) {
if (window.getComputedStyle(tooltips[i]).display === "block") {
return tooltips[i];
}
}
return null;
}

module.exports = {
setUp : function(done) {
this.editor = new Editor(new VirtualRenderer());
Expand All @@ -43,7 +53,7 @@ module.exports = {
editor.renderer.$loop._flush();

var lines = editor.renderer.$gutterLayer.$lines;
var toggler = lines.cells[0].element.children[1];
var toggler = lines.cells[0].element.querySelector(".ace_fold-widget");

// Set focus to the gutter div.
editor.renderer.$gutter.focus();
Expand Down Expand Up @@ -153,7 +163,7 @@ module.exports = {
setTimeout(function() {
// Check annotation is rendered.
editor.renderer.$loop._flush();
var tooltip = editor.container.querySelector(".ace_gutter-tooltip");
var tooltip = findVisibleTooltip();
assert.ok(/error test/.test(tooltip.textContent));

// Press escape to dismiss the tooltip.
Expand All @@ -164,7 +174,7 @@ module.exports = {
assert.equal(document.activeElement, editor.renderer.$gutter);

done();
}, 20);
}, 400);
}, 20);
},"test: keyboard annotation: multiple annotations" : function(done) {
var editor = this.editor;
Expand Down Expand Up @@ -198,7 +208,7 @@ module.exports = {
setTimeout(function() {
// Check annotation is rendered.
editor.renderer.$loop._flush();
var tooltip = editor.container.querySelector(".ace_gutter-tooltip");
var tooltip = findVisibleTooltip();
assert.ok(/error test/.test(tooltip.textContent));

// Press escape to dismiss the tooltip.
Expand All @@ -214,7 +224,7 @@ module.exports = {
setTimeout(function() {
// Check annotation is rendered.
editor.renderer.$loop._flush();
var tooltip = editor.container.querySelector(".ace_gutter-tooltip");
var tooltip = findVisibleTooltip();
assert.ok(/warning test/.test(tooltip.textContent));

// Press escape to dismiss the tooltip.
Expand Down Expand Up @@ -376,7 +386,7 @@ module.exports = {
setTimeout(function() {
// Check annotation is rendered.
editor.renderer.$loop._flush();
var tooltip = editor.container.querySelector(".ace_gutter-tooltip");
var tooltip = findVisibleTooltip();
assert.ok(/error test/.test(tooltip.textContent));

// Press escape to dismiss the tooltip.
Expand Down
Loading
Loading