Editor: when in applies-to, use its code box for search
This commit is contained in:
parent
83b2e1d53d
commit
451b392034
15
edit.js
15
edit.js
|
@ -468,7 +468,7 @@ function setupGlobalSearch() {
|
||||||
findNext(cm, true);
|
findNext(cm, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getVisibleEditor() {
|
function getVisibleEditor(activeElement) {
|
||||||
var linesVisible = 2; // closest editor should have at least # lines visible
|
var linesVisible = 2; // closest editor should have at least # lines visible
|
||||||
function getScrollDistance(cm) {
|
function getScrollDistance(cm) {
|
||||||
var bounds = cm.display.wrapper.parentNode.getBoundingClientRect();
|
var bounds = cm.display.wrapper.parentNode.getBoundingClientRect();
|
||||||
|
@ -480,6 +480,17 @@ function setupGlobalSearch() {
|
||||||
return bounds.top - bounds.height;
|
return bounds.top - bounds.height;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (activeElement && activeElement.className.indexOf("applies-") >= 0) {
|
||||||
|
for (var section = activeElement; section.parentNode; section = section.parentNode) {
|
||||||
|
var cmWrapper = section.querySelector(".CodeMirror");
|
||||||
|
if (cmWrapper) {
|
||||||
|
if (getScrollDistance(cmWrapper.CodeMirror) == 0) {
|
||||||
|
return cmWrapper.CodeMirror;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if (editors.lastActive && getScrollDistance(editors.lastActive) == 0) {
|
if (editors.lastActive && getScrollDistance(editors.lastActive) == 0) {
|
||||||
return editors.lastActive;
|
return editors.lastActive;
|
||||||
}
|
}
|
||||||
|
@ -498,7 +509,7 @@ function setupGlobalSearch() {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
if (!event.target.classList.contains("CodeMirror-search-field")) {
|
if (!event.target.classList.contains("CodeMirror-search-field")) {
|
||||||
CodeMirror.commands[command](getVisibleEditor());
|
CodeMirror.commands[command](getVisibleEditor(event.target));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user