Merge pull request #96 from tophf/search-box-select
Editor: when in applies-to, use its code box for search on Ctrl-F, etc.
This commit is contained in:
commit
8200a7c483
15
edit.js
15
edit.js
|
@ -468,7 +468,7 @@ function setupGlobalSearch() {
|
|||
findNext(cm, true);
|
||||
}
|
||||
|
||||
function getVisibleEditor() {
|
||||
function getVisibleEditor(activeElement) {
|
||||
var linesVisible = 2; // closest editor should have at least # lines visible
|
||||
function getScrollDistance(cm) {
|
||||
var bounds = cm.display.wrapper.parentNode.getBoundingClientRect();
|
||||
|
@ -480,6 +480,17 @@ function setupGlobalSearch() {
|
|||
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) {
|
||||
return editors.lastActive;
|
||||
}
|
||||
|
@ -498,7 +509,7 @@ function setupGlobalSearch() {
|
|||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
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