Merge pull request #2275 from ethereum/fpanel

catch filepanel activation
pull/5370/head
yann300 3 years ago committed by GitHub
commit 43c21317d7
  1. 24
      libs/remix-ui/search/src/lib/context/context.tsx

@ -45,7 +45,7 @@ export interface SearchingStateInterface {
replaceAllInFile: (result: SearchResult) => Promise<void> replaceAllInFile: (result: SearchResult) => Promise<void>
undoReplace: (buffer: undoBufferRecord) => Promise<void> undoReplace: (buffer: undoBufferRecord) => Promise<void>
clearUndo: () => void clearUndo: () => void
cancelSearch: (clearResults?:boolean) => Promise<void> cancelSearch: (clearResults?: boolean) => Promise<void>
startSearch: () => void startSearch: () => void
} }
@ -111,7 +111,7 @@ export const SearchProvider = ({
payload: value payload: value
}) })
}, },
setSearchResults(value: SearchResult[]) { setSearchResults(value: SearchResult[]) {
dispatch({ dispatch({
type: 'SET_SEARCH_RESULTS', type: 'SET_SEARCH_RESULTS',
payload: value payload: value
@ -285,7 +285,7 @@ export const SearchProvider = ({
}, },
clearStats: () => { clearStats: () => {
plugin.call('editor', 'discardHighlight') plugin.call('editor', 'discardHighlight')
dispatch({ dispatch({
type: 'CLEAR_STATS', type: 'CLEAR_STATS',
payload: undefined payload: undefined
@ -294,7 +294,7 @@ export const SearchProvider = ({
cancelSearch: async (clearResults = true) => { cancelSearch: async (clearResults = true) => {
plugin.cancel('fileManager') plugin.cancel('fileManager')
if(clearResults) value.clearStats() if (clearResults) value.clearStats()
value.setRun(false) value.setRun(false)
}, },
@ -323,10 +323,10 @@ export const SearchProvider = ({
}) })
plugin.on('fileManager', 'rootFolderChanged', async file => { plugin.on('fileManager', 'rootFolderChanged', async file => {
const workspace = await plugin.call('filePanel', 'getCurrentWorkspace') const workspace = await plugin.call('filePanel', 'getCurrentWorkspace')
if(workspace) value.setCurrentWorkspace(workspace.name) if (workspace) value.setCurrentWorkspace(workspace.name)
setFiles(await getDirectory('/', plugin)) setFiles(await getDirectory('/', plugin))
}) })
plugin.on('fileManager', 'fileAdded', async file => { plugin.on('fileManager', 'fileAdded', async file => {
setFiles(await getDirectory('/', plugin)) setFiles(await getDirectory('/', plugin))
await reloadStateForFile(file) await reloadStateForFile(file)
@ -336,9 +336,13 @@ export const SearchProvider = ({
await checkUndoState(file) await checkUndoState(file)
}) })
async function fetchWorkspace() { async function fetchWorkspace() {
const workspace = await plugin.call('filePanel', 'getCurrentWorkspace') try {
if(workspace) value.setCurrentWorkspace(workspace.name) const workspace = await plugin.call('filePanel', 'getCurrentWorkspace')
setFiles(await getDirectory('/', plugin)) if (workspace) value.setCurrentWorkspace(workspace.name)
setFiles(await getDirectory('/', plugin))
} catch (e) {
console.log(e)
}
} }
fetchWorkspace() fetchWorkspace()
@ -402,7 +406,7 @@ export const SearchProvider = ({
} }
useEffect(() => { useEffect(() => {
if(state.count>500) { if (state.count > 500) {
value.setClipped(true) value.setClipped(true)
value.cancelSearch(false) value.cancelSearch(false)
} }

Loading…
Cancel
Save