editor: fix parents expanding on every transaction

This commit is contained in:
Abdullah Atta
2026-05-21 11:38:23 +05:00
parent 4e6ab98d9b
commit fc2e4cef0b

View File

@@ -297,6 +297,7 @@ export const SearchReplace = Extension.create<SearchOptions, SearchStorage>({
);
this.storage.selectedIndex = nextIndex;
tr.setMeta("isSearching", true);
tr.setMeta("selectedIndex", nextIndex);
if (dispatch) updateView(state, dispatch);
@@ -322,6 +323,7 @@ export const SearchReplace = Extension.create<SearchOptions, SearchStorage>({
);
this.storage.selectedIndex = prevIndex;
tr.setMeta("isSearching", true);
tr.setMeta("selectedIndex", prevIndex);
if (dispatch) updateView(state, dispatch);
@@ -468,10 +470,12 @@ export const SearchReplace = Extension.create<SearchOptions, SearchStorage>({
}
},
appendTransaction: (transactions, oldState, newState) => {
const { isSearching } = key.getState(newState);
const isSearchTransaction = transactions.find((t) =>
t.getMeta("isSearching")
);
const selectedResult =
this.storage.results?.[this.storage.selectedIndex];
if (!isSearching || !selectedResult) return;
if (!isSearchTransaction || !selectedResult) return;
const tr = newState.tr;
if (expandCollapsedParents(tr, selectedResult.from)) {