From 2d218841e84fd1fef43e14c862aa232f581fc732 Mon Sep 17 00:00:00 2001 From: filip mertens Date: Sun, 10 Apr 2022 15:32:20 +0200 Subject: [PATCH 1/2] catch filepanel activation --- .../search/src/lib/context/context.tsx | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/libs/remix-ui/search/src/lib/context/context.tsx b/libs/remix-ui/search/src/lib/context/context.tsx index a719209a42..0ad300edb1 100644 --- a/libs/remix-ui/search/src/lib/context/context.tsx +++ b/libs/remix-ui/search/src/lib/context/context.tsx @@ -45,7 +45,7 @@ export interface SearchingStateInterface { replaceAllInFile: (result: SearchResult) => Promise undoReplace: (buffer: undoBufferRecord) => Promise clearUndo: () => void - cancelSearch: (clearResults?:boolean) => Promise + cancelSearch: (clearResults?: boolean) => Promise startSearch: () => void } @@ -111,7 +111,7 @@ export const SearchProvider = ({ payload: value }) }, - setSearchResults(value: SearchResult[]) { + setSearchResults(value: SearchResult[]) { dispatch({ type: 'SET_SEARCH_RESULTS', payload: value @@ -285,7 +285,7 @@ export const SearchProvider = ({ }, clearStats: () => { - plugin.call('editor', 'discardHighlight') + plugin.call('editor', 'discardHighlight') dispatch({ type: 'CLEAR_STATS', payload: undefined @@ -294,7 +294,7 @@ export const SearchProvider = ({ cancelSearch: async (clearResults = true) => { plugin.cancel('fileManager') - if(clearResults) value.clearStats() + if (clearResults) value.clearStats() value.setRun(false) }, @@ -323,10 +323,10 @@ export const SearchProvider = ({ }) plugin.on('fileManager', 'rootFolderChanged', async file => { const workspace = await plugin.call('filePanel', 'getCurrentWorkspace') - if(workspace) value.setCurrentWorkspace(workspace.name) + if (workspace) value.setCurrentWorkspace(workspace.name) setFiles(await getDirectory('/', plugin)) }) - + plugin.on('fileManager', 'fileAdded', async file => { setFiles(await getDirectory('/', plugin)) await reloadStateForFile(file) @@ -336,9 +336,12 @@ export const SearchProvider = ({ await checkUndoState(file) }) async function fetchWorkspace() { - const workspace = await plugin.call('filePanel', 'getCurrentWorkspace') - if(workspace) value.setCurrentWorkspace(workspace.name) - setFiles(await getDirectory('/', plugin)) + try { + const workspace = await plugin.call('filePanel', 'getCurrentWorkspace') + if (workspace) value.setCurrentWorkspace(workspace.name) + setFiles(await getDirectory('/', plugin)) + } catch (e) { + } } fetchWorkspace() @@ -402,7 +405,7 @@ export const SearchProvider = ({ } useEffect(() => { - if(state.count>500) { + if (state.count > 500) { value.setClipped(true) value.cancelSearch(false) } From 294fbd74407415f88c46eabff92191549a1599b7 Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 11 Apr 2022 14:36:18 +0200 Subject: [PATCH 2/2] add log --- libs/remix-ui/search/src/lib/context/context.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/libs/remix-ui/search/src/lib/context/context.tsx b/libs/remix-ui/search/src/lib/context/context.tsx index 0ad300edb1..c59ec33576 100644 --- a/libs/remix-ui/search/src/lib/context/context.tsx +++ b/libs/remix-ui/search/src/lib/context/context.tsx @@ -341,6 +341,7 @@ export const SearchProvider = ({ if (workspace) value.setCurrentWorkspace(workspace.name) setFiles(await getDirectory('/', plugin)) } catch (e) { + console.log(e) } }