Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.
Closed
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
78 changes: 44 additions & 34 deletions src/extensions/default/QuickView/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ define(function (require, exports, module) {
prefs = null, // Preferences
$previewContainer, // Preview container
$previewContent, // Preview content holder
lastPos; // Last line/ch pos processed by handleMouseMove
lastPos, // Last line/ch pos processed by handleMouseMove
lastMouseEvent; // Last mouse event processed by handleMouseMove

// Constants
var CMD_ENABLE_QUICK_VIEW = "view.enableQuickView",
Expand Down Expand Up @@ -340,7 +341,7 @@ define(function (require, exports, module) {
params[i] = args.join(" ");
}

// put it back together.
// put it back together.
expression = expression.substring(0, paramStart) + params.join(", ") + expression.substring(paramEnd);
}
return expression;
Expand Down Expand Up @@ -516,6 +517,42 @@ define(function (require, exports, module) {
return null;
}

function getHoveredEditor(event) {
// Figure out which editor we are over
var fullEditor = EditorManager.getCurrentFullEditor();

if (!fullEditor) {
return;
}

// Check for inline Editor instances first
var inlines = fullEditor.getInlineWidgets(),
i,
editor;

for (i = 0; i < inlines.length; i++) {
var $inlineEditorRoot = inlines[i].editor && $(inlines[i].editor.getRootElement()), // see MultiRangeInlineEditor
$otherDiv = inlines[i].$htmlContent;

if ($inlineEditorRoot && divContainsMouse($inlineEditorRoot, event)) {
editor = inlines[i].editor;
break;
} else if ($otherDiv && divContainsMouse($otherDiv, event)) {
// Mouse inside unsupported inline editor like Quick Docs or Color Editor
return;
}
}

// Check main editor
if (!editor) {
if (divContainsMouse($(fullEditor.getRootElement()), event)) {
editor = fullEditor;
}
}

return editor;
}

/**
* Changes the current hidden popoverState to visible, showing it in the UI and highlighting
* its matching text in the editor.
Expand Down Expand Up @@ -563,39 +600,12 @@ define(function (require, exports, module) {
return;
}

// Figure out which editor we are over
var fullEditor = EditorManager.getCurrentFullEditor();

if (!fullEditor) {
hidePreview();
if (lastMouseEvent && lastMouseEvent.clientX === event.clientX && lastMouseEvent.clientY === event.clientY) {
return;
}
lastMouseEvent = event;

// Check for inline Editor instances first
var inlines = fullEditor.getInlineWidgets(),
i,
editor;

for (i = 0; i < inlines.length; i++) {
var $inlineEditorRoot = inlines[i].editor && $(inlines[i].editor.getRootElement()), // see MultiRangeInlineEditor
$otherDiv = inlines[i].$htmlContent;

if ($inlineEditorRoot && divContainsMouse($inlineEditorRoot, event)) {
editor = inlines[i].editor;
break;
} else if ($otherDiv && divContainsMouse($otherDiv, event)) {
// Mouse inside unsupported inline editor like Quick Docs or Color Editor
hidePreview();
return;
}
}

// Check main editor
if (!editor) {
if (divContainsMouse($(fullEditor.getRootElement()), event)) {
editor = fullEditor;
}
}
var editor = getHoveredEditor(event);

if (editor && editor._codeMirror) {
// Find char mouse is over
Expand All @@ -622,7 +632,7 @@ define(function (require, exports, module) {
// That one's still relevant - nothing more to do
return;
} else {
// That one doesn't cover this pos - hide it and start anew
// That one doesn't cover this pos - hide it and start a new
showImmediately = popoverState.visible;
hidePreview();
}
Expand All @@ -640,7 +650,7 @@ define(function (require, exports, module) {
}, showImmediately ? 0 : HOVER_DELAY);

} else {
// Mouse not over any Editor - immediately hide popover
// Mouse not over any supported Editor - immediately hide popover
hidePreview();
}
}
Expand Down