Skip to content
Snippets Groups Projects
Commit 593dd0c8 authored by chris's avatar chris
Browse files

fix empty results by view

parent e633113b
No related branches found
No related tags found
1 merge request!243Feature improvments
......@@ -74,7 +74,7 @@ const FindAndReplaceComponent = ({ close }) => {
if (!resultsFrom[lastActiveViewId]) {
view[findViewWithMatches].dispatch(
view[findViewWithMatches].state.tr.setSelection(
new TextSelection(view[findViewWithMatches].state.tr.doc.resolve(1)),
new TextSelection(view[findViewWithMatches].state.tr.doc.resolve(0)),
),
);
view[findViewWithMatches].focus();
......@@ -152,7 +152,11 @@ const FindAndReplaceComponent = ({ close }) => {
if (!resultsFrom[lastActiveViewId]) {
view[findViewWithMatches].dispatch(
view[findViewWithMatches].state.tr.setSelection(
new TextSelection(view[findViewWithMatches].state.tr.doc.resolve(1)),
new TextSelection(
view[findViewWithMatches].state.tr.doc.resolve(
view[findViewWithMatches].state.doc.content.size,
),
),
),
);
view[findViewWithMatches].focus();
......@@ -165,6 +169,7 @@ const FindAndReplaceComponent = ({ close }) => {
resultsFrom[lastActiveViewId],
false,
);
const position = resultsFrom[lastActiveViewId].indexOf(found);
/* User selection lesser than found */
......
......@@ -150,21 +150,23 @@ const findViewWithMatchesBackWards = (results, view, lastActiveViewId) => {
}
}
if (notesIds.indexOf(lastActiveViewId) < notesIds.length - 1) {
for (let i = 0; i < notesIds.length; i += 1) {
if (notesIds.indexOf(lastActiveViewId) !== 0) {
for (let i = notesIds.indexOf(lastActiveViewId) - 1; i >= 0; i -= 1) {
if (results[notesIds[i]].length > 0) {
return notesIds[i];
}
if (results.main.length > 0) return 'main';
}
} else if (results.main.length > 0) {
return 'main';
} else {
for (let i = notesIds.length - 1; i >= 0; i -= 1) {
if (results[notesIds[i]].length > 0) {
return notesIds[i];
}
}
}
if (
notesIds.indexOf(lastActiveViewId) &&
notesIds.indexOf(lastActiveViewId) === notesIds.length - 1
) {
return 'main';
}
return false;
};
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment