From f7e80c27c6df27527e6cea8d562b06cb6d3b9f68 Mon Sep 17 00:00:00 2001 From: Milad Gueramian Date: Wed, 6 Apr 2022 02:56:18 -0700 Subject: [PATCH 01/14] contain text in container --- libs/remix-ui/workspace/src/lib/components/file-label.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/remix-ui/workspace/src/lib/components/file-label.tsx b/libs/remix-ui/workspace/src/lib/components/file-label.tsx index 0e2fb83829..ed5b75e628 100644 --- a/libs/remix-ui/workspace/src/lib/components/file-label.tsx +++ b/libs/remix-ui/workspace/src/lib/components/file-label.tsx @@ -48,7 +48,7 @@ export const FileLabel = (props: FileLabelProps) => { return (
Date: Thu, 17 Mar 2022 10:45:06 +0100 Subject: [PATCH 02/14] performance --- .../remix-ui/search/src/lib/components/Find.tsx | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/libs/remix-ui/search/src/lib/components/Find.tsx b/libs/remix-ui/search/src/lib/components/Find.tsx index 377c269533..845eed7c0c 100644 --- a/libs/remix-ui/search/src/lib/components/Find.tsx +++ b/libs/remix-ui/search/src/lib/components/Find.tsx @@ -1,20 +1,28 @@ -import React, { useContext, useRef } from 'react' +import React, { useContext, useEffect, useRef, useState } from 'react' import { SearchContext } from '../context/context' export const Find = () => { const { setFind, + cancelSearch, state, toggleCaseSensitive, toggleMatchWholeWord, toggleUseRegex } = useContext(SearchContext) const timeOutId = useRef(null) - const change = e => { + const [inputValue, setInputValue] = useState(""); + const change = async(e) => { + setInputValue(e.target.value) clearTimeout(timeOutId.current) - timeOutId.current = setTimeout(() => setFind(e.target.value), 500) + await cancelSearch() + timeOutId.current = setTimeout(async () => await setFind(e.target.value), 500) } + useEffect(() =>{ + setInputValue('') + },[state.workspace]) + return ( <>
@@ -23,7 +31,8 @@ export const Find = () => { id='search_input' placeholder="Search" className="form-control" - onChange={change} + value={inputValue} + onChange={async(e) => await change(e)} >
Date: Thu, 17 Mar 2022 10:45:16 +0100 Subject: [PATCH 03/14] performance --- .../src/lib/components/CancelSearch.tsx | 13 ++ .../search/src/lib/components/Exclude.tsx | 9 +- .../search/src/lib/components/Include.tsx | 7 +- .../search/src/lib/components/Search.tsx | 28 ++- .../src/lib/components/results/ResultItem.tsx | 21 +- .../src/lib/components/results/Results.tsx | 22 ++- .../search/src/lib/context/context.tsx | 186 +++++++++++------- .../search/src/lib/reducers/Reducer.ts | 30 ++- libs/remix-ui/search/src/lib/search.css | 5 + libs/remix-ui/search/src/lib/types/index.ts | 6 +- 10 files changed, 212 insertions(+), 115 deletions(-) create mode 100644 libs/remix-ui/search/src/lib/components/CancelSearch.tsx diff --git a/libs/remix-ui/search/src/lib/components/CancelSearch.tsx b/libs/remix-ui/search/src/lib/components/CancelSearch.tsx new file mode 100644 index 0000000000..5461c5ebec --- /dev/null +++ b/libs/remix-ui/search/src/lib/components/CancelSearch.tsx @@ -0,0 +1,13 @@ +import React from "react" +import { useContext } from "react" +import { SearchContext } from "../context/context" + +export const CacncelSearch = () => { + const { cancelSearch } = useContext(SearchContext) + const cancel = async () => { + await cancelSearch() + } + return ( + await cancel()}>stop + ) +} \ No newline at end of file diff --git a/libs/remix-ui/search/src/lib/components/Exclude.tsx b/libs/remix-ui/search/src/lib/components/Exclude.tsx index 5385783324..cd9aaf07bc 100644 --- a/libs/remix-ui/search/src/lib/components/Exclude.tsx +++ b/libs/remix-ui/search/src/lib/components/Exclude.tsx @@ -2,12 +2,13 @@ import React, { useContext, useEffect, useRef, useState } from 'react' import { SearchContext } from '../context/context' export const Exclude = props => { - const { setExclude, state } = useContext(SearchContext) - const [excludeInput, setExcludeInput] = useState('.git/**/*,.deps/**/*') + const { setExclude, cancelSearch } = useContext(SearchContext) + const [excludeInput, setExcludeInput] = useState('.*/**/*') const timeOutId = useRef(null) - const change = e => { + const change = async e => { setExcludeInput(e.target.value) clearTimeout(timeOutId.current) + await cancelSearch() timeOutId.current = setTimeout(() => setExclude(e.target.value), 500) } @@ -23,7 +24,7 @@ export const Exclude = props => { id='search_exclude' placeholder="Exclude ie .git/**/*" className="form-control" - onChange={change} + onChange={async(e) => change(e)} value={excludeInput} >
diff --git a/libs/remix-ui/search/src/lib/components/Include.tsx b/libs/remix-ui/search/src/lib/components/Include.tsx index 1d3f8faf96..c0284d1b24 100644 --- a/libs/remix-ui/search/src/lib/components/Include.tsx +++ b/libs/remix-ui/search/src/lib/components/Include.tsx @@ -2,12 +2,13 @@ import React, { useContext, useRef, useState } from 'react' import { SearchContext } from '../context/context' export const Include = props => { - const { setInclude } = useContext(SearchContext) + const { setInclude, cancelSearch } = useContext(SearchContext) const [includeInput, setIncludeInput] = useState('') const timeOutId = useRef(null) - const change = e => { + const change = async e => { setIncludeInput(e.target.value) clearTimeout(timeOutId.current) + await cancelSearch() timeOutId.current = setTimeout(() => setInclude(e.target.value), 500) } @@ -19,7 +20,7 @@ export const Include = props => { id='search_include' placeholder="Include ie contracts/**/*.sol" className="form-control" - onChange={change} + onChange={async(e) => change(e)} value={includeInput} >
diff --git a/libs/remix-ui/search/src/lib/components/Search.tsx b/libs/remix-ui/search/src/lib/components/Search.tsx index 7f6d62aa5e..3dee1711e8 100644 --- a/libs/remix-ui/search/src/lib/components/Search.tsx +++ b/libs/remix-ui/search/src/lib/components/Search.tsx @@ -1,30 +1,28 @@ -import React from 'react' +import React, { useContext } from 'react' import { SearchProvider } from '../context/context' -import { Find } from './Find' import { Results } from './results/Results' import '../search.css' import { Include } from './Include' import { Exclude } from './Exclude' -import { Replace } from './Replace' -import { OverWriteCheck } from './OverWriteCheck' import { FindContainer } from './FindContainer' import { Undo } from './Undo' +import { CacncelSearch } from './CancelSearch' export const SearchTab = props => { -const plugin = props.plugin + const plugin = props.plugin -return ( + return ( <> -
- - - - - - - -
+
+ + + + + + + +
) } diff --git a/libs/remix-ui/search/src/lib/components/results/ResultItem.tsx b/libs/remix-ui/search/src/lib/components/results/ResultItem.tsx index 91fb1c6042..0c36c057a7 100644 --- a/libs/remix-ui/search/src/lib/components/results/ResultItem.tsx +++ b/libs/remix-ui/search/src/lib/components/results/ResultItem.tsx @@ -7,6 +7,7 @@ import { ResultSummary } from './ResultSummary' interface ResultItemProps { file: SearchResult + index: number } export const ResultItem = (props: ResultItemProps) => { @@ -17,6 +18,7 @@ export const ResultItem = (props: ResultItemProps) => { const [lines, setLines] = useState([]) const [toggleExpander, setToggleExpander] = useState(false) const reloadTimeOut = useRef(null) + const loadTimeout = useRef(null) const subscribed = useRef(true) const { modal } = useDialogDispatchers() @@ -27,6 +29,7 @@ export const ResultItem = (props: ResultItemProps) => { useEffect(() => { if (props.file.forceReload) { clearTimeout(reloadTimeOut.current) + clearTimeout(loadTimeout.current) reloadTimeOut.current = setTimeout(() => reload(), 1000) } }, [props.file.forceReload]) @@ -35,14 +38,11 @@ export const ResultItem = (props: ResultItemProps) => { setToggleExpander(!toggleExpander) } - useEffect(() => { - reload() - }, [state.find]) - useEffect(() => { subscribed.current = true return () => { - updateCount(0, props.file.filename) + clearTimeout(reloadTimeOut.current) + clearTimeout(loadTimeout.current) subscribed.current = false } }, []) @@ -64,7 +64,7 @@ export const ResultItem = (props: ResultItemProps) => { } } - const reload = () => { + const doLoad = () => { findText(props.file.filename).then(res => { if (subscribed.current) { setLines(res) @@ -78,9 +78,15 @@ export const ResultItem = (props: ResultItemProps) => { setLoading(false) disableForceReload(props.file.filename) } + }).catch((e) => { + console.error(e) }) } + const reload = () => { + loadTimeout.current = setTimeout(doLoad, 150 * props.index) + } + return ( <> {lines && lines.length ? ( @@ -110,13 +116,12 @@ export const ResultItem = (props: ResultItemProps) => {
:null} {lines.map((line, index) => ( - index < state.maxLines ? : null + /> ))}
) : null} diff --git a/libs/remix-ui/search/src/lib/components/results/Results.tsx b/libs/remix-ui/search/src/lib/components/results/Results.tsx index 3e5472915a..4d16f05235 100644 --- a/libs/remix-ui/search/src/lib/components/results/Results.tsx +++ b/libs/remix-ui/search/src/lib/components/results/Results.tsx @@ -5,12 +5,26 @@ import { ResultItem } from './ResultItem' export const Results = () => { const { state } = useContext(SearchContext) return ( -
- {state.find ?
showing {state.count} results {state.fileCount} in files
: null} - {state.find && state.clipped?
The result set only shows a subset of all matches

Please narrow down your search.
: null} +
+
+ {' '} + {state.searching && !state.clipped + ? `searching in ${state.searching}` + : null} +
+ {state.find && !state.clipped ? ( +
+ showing {state.count} results {state.fileCount} in files +
+ ) : null} + {state.find && state.clipped ? ( +
+ Too many resuls to display...

Please narrow down your search. +
+ ) : null} {state.searchResults && state.searchResults.map((result, index) => { - return index : null + return })}
) diff --git a/libs/remix-ui/search/src/lib/context/context.tsx b/libs/remix-ui/search/src/lib/context/context.tsx index 6d270ba1b2..a8d3a7fab0 100644 --- a/libs/remix-ui/search/src/lib/context/context.tsx +++ b/libs/remix-ui/search/src/lib/context/context.tsx @@ -1,4 +1,4 @@ -import React, { useEffect, useRef } from 'react' +import React, { useEffect, useRef, useState } from 'react' import { createContext, useReducer } from 'react' import { findLinesInStringWithMatch, @@ -31,7 +31,10 @@ export interface SearchingStateInterface { setSearchResults: (value: SearchResult[]) => void findText: (path: string) => Promise hightLightInPath: (result: SearchResult, line: SearchResultLineLine) => void - replaceText: (result: SearchResult, line: SearchResultLineLine) => Promise + replaceText: ( + result: SearchResult, + line: SearchResultLineLine + ) => Promise reloadFile: (file: string) => void toggleCaseSensitive: () => void toggleMatchWholeWord: () => void @@ -39,9 +42,10 @@ export interface SearchingStateInterface { setReplaceWithoutConfirmation: (value: boolean) => void disableForceReload: (file: string) => void updateCount: (count: number, file: string) => void - replaceAllInFile: (result: SearchResult) => Promise + replaceAllInFile: (result: SearchResult) => Promise undoReplace: (buffer: undoBufferRecord) => Promise clearUndo: () => void + cancelSearch: () => Promise } export const SearchContext = createContext(null) @@ -53,11 +57,12 @@ export const SearchProvider = ({ plugin = undefined } = {}) => { const [state, dispatch] = useReducer(reducer, initialState) - - const reloadTimeOut = useRef(null) + const [files, setFiles] = useState([]) + const clearSearchingTimeout = useRef(null) const value = { state, setFind: (value: string) => { + plugin.cancel('fileManager') dispatch({ type: 'SET_FIND', payload: value @@ -165,14 +170,30 @@ export const SearchProvider = ({ payload: { count, file } }) }, + setSearching(file: string) { + dispatch({ + type: 'SET_SEARCHING', + payload: file + }) + }, + findText: async (path: string) => { if (!plugin) return try { if (state.find.length < 1) return + value.setSearching(path) const text = await plugin.call('fileManager', 'readFile', path) - const result: SearchResultLine[] = findLinesInStringWithMatch(text, createRegExFromFind()) + const result: SearchResultLine[] = findLinesInStringWithMatch( + text, + createRegExFromFind() + ) + clearTimeout(clearSearchingTimeout.current) + clearSearchingTimeout.current = setTimeout(() => value.setSearching(null), 500) return result - } catch (e) { } + } catch (e) { + value.setSearching(null) + // do nothing + } }, hightLightInPath: async ( result: SearchResult, @@ -180,7 +201,14 @@ export const SearchProvider = ({ ) => { await plugin.call('editor', 'discardHighlight') await plugin.call('editor', 'highlight', line.position, result.path) - await plugin.call('editor', 'revealRange', line.position.start.line, line.position.start.column, line.position.end.line, line.position.end.column) + await plugin.call( + 'editor', + 'revealRange', + line.position.start.line, + line.position.start.column, + line.position.end.line, + line.position.end.column + ) }, replaceText: async (result: SearchResult, line: SearchResultLineLine) => { try { @@ -192,12 +220,7 @@ export const SearchProvider = ({ result.path ) const replaced = replaceTextInLine(content, line, state.replace) - await plugin.call( - 'fileManager', - 'setFile', - result.path, - replaced - ) + await plugin.call('fileManager', 'setFile', result.path, replaced) setUndoState(content, replaced, result.path) } catch (e) { throw new Error(e) @@ -205,26 +228,17 @@ export const SearchProvider = ({ }, replaceAllInFile: async (result: SearchResult) => { await plugin.call('editor', 'discardHighlight') - const content = await plugin.call( - 'fileManager', - 'readFile', - result.path - ) - const replaced = replaceAllInFile(content, createRegExFromFind(), state.replace) - await plugin.call( - 'fileManager', - 'setFile', - result.path, - replaced - ) - await plugin.call( - 'fileManager', - 'open', - result.path + const content = await plugin.call('fileManager', 'readFile', result.path) + const replaced = replaceAllInFile( + content, + createRegExFromFind(), + state.replace ) + await plugin.call('fileManager', 'setFile', result.path, replaced) + await plugin.call('fileManager', 'open', result.path) setUndoState(content, replaced, result.path) }, - setUndoEnabled: (path:string, workspace: string, content: string) => { + setUndoEnabled: (path: string, workspace: string, content: string) => { dispatch({ type: 'SET_UNDO_ENABLED', payload: { @@ -235,11 +249,7 @@ export const SearchProvider = ({ }) }, undoReplace: async (buffer: undoBufferRecord) => { - const content = await plugin.call( - 'fileManager', - 'readFile', - buffer.path - ) + const content = await plugin.call('fileManager', 'readFile', buffer.path) if (buffer.newContent !== content) { throw new Error('Can not undo replace, file has been changed.') } @@ -249,41 +259,58 @@ export const SearchProvider = ({ buffer.path, buffer.oldContent ) - await plugin.call( - 'fileManager', - 'open', - buffer.path - ) + await plugin.call('fileManager', 'open', buffer.path) }, clearUndo: () => { - dispatch ({ + dispatch({ type: 'CLEAR_UNDO', payload: undefined }) - } - } + }, + clearStats: () => { + dispatch({ + type: 'CLEAR_STATS', + payload: undefined + }) + }, + + cancelSearch: async () => { + plugin.cancel('fileManager') + value.clearStats() + }, + setClipped: (value: boolean) => { + dispatch({ + type: 'SET_CLIPPED', + payload: value + }) + } + } const reloadStateForFile = async (file: string) => { await value.reloadFile(file) } useEffect(() => { - plugin.on('filePanel', 'setWorkspace', async (workspace) => { + plugin.on('filePanel', 'setWorkspace', async workspace => { value.setSearchResults(null) value.clearUndo() value.setCurrentWorkspace(workspace.name) + setFiles(await getDirectory('/', plugin)) }) plugin.on('fileManager', 'fileSaved', async file => { await reloadStateForFile(file) await checkUndoState(file) }) + plugin.on('fileManager', 'fileAdded', async file => { + setFiles(await getDirectory('/', plugin)) + }) plugin.on('fileManager', 'currentFileChanged', async file => { value.setCurrentFile(file) await checkUndoState(file) }) - + return () => { plugin.off('fileManager', 'fileChanged') plugin.off('filePanel', 'setWorkspace') @@ -296,7 +323,8 @@ export const SearchProvider = ({ paths.split(',').forEach(path => { path = path.trim() if (path.startsWith('*.')) path = path.replace(/(\*\.)/g, '**/*.') - if (path.endsWith('/*') && !path.endsWith('/**/*')) path = path.replace(/(\*)/g, '**/*.*') + if (path.endsWith('/*') && !path.endsWith('/**/*')) + path = path.replace(/(\*)/g, '**/*.*') results.push(path) }) return results @@ -305,19 +333,19 @@ export const SearchProvider = ({ const checkUndoState = async (path: string) => { if (!plugin) return try { - const content = await plugin.call( - 'fileManager', - 'readFile', - path - ) + const content = await plugin.call('fileManager', 'readFile', path) const workspace = await plugin.call('filePanel', 'getCurrentWorkspace') value.setUndoEnabled(path, workspace.name, content) - } catch (e) { + } catch (e) { console.log(e) } } - const setUndoState = async (oldContent: string, newContent: string, path: string) => { + const setUndoState = async ( + oldContent: string, + newContent: string, + path: string + ) => { const workspace = await plugin.call('filePanel', 'getCurrentWorkspace') const undo = { oldContent, @@ -341,29 +369,41 @@ export const SearchProvider = ({ return re } + useEffect(() => { + if(state.count>500) { + value.setClipped(true) + value.cancelSearch() + } + }, [state.count]) + useEffect(() => { if (state.find) { (async () => { - const files = await getDirectory('/', plugin) - const pathFilter: any = {} - if (state.include) { - pathFilter.include = setGlobalExpression(state.include) - } - if (state.exclude) { - pathFilter.exclude = setGlobalExpression(state.exclude) - } - const filteredFiles = files.filter(filePathFilter(pathFilter)).map(file => { - const r: SearchResult = { - filename: file, - lines: [], - path: file, - timeStamp: Date.now(), - forceReload: false, - count: 0 + try { + const pathFilter: any = {} + if (state.include) { + pathFilter.include = setGlobalExpression(state.include) + } + if (state.exclude) { + pathFilter.exclude = setGlobalExpression(state.exclude) } - return r - }) - value.setSearchResults(filteredFiles) + const filteredFiles = files + .filter(filePathFilter(pathFilter)) + .map(file => { + const r: SearchResult = { + filename: file, + lines: [], + path: file, + timeStamp: Date.now(), + forceReload: false, + count: 0 + } + return r + }) + value.setSearchResults(filteredFiles) + } catch (e) { + console.log(e) + } })() } }, [state.timeStamp]) diff --git a/libs/remix-ui/search/src/lib/reducers/Reducer.ts b/libs/remix-ui/search/src/lib/reducers/Reducer.ts index 3e188f61fb..1455dab61e 100644 --- a/libs/remix-ui/search/src/lib/reducers/Reducer.ts +++ b/libs/remix-ui/search/src/lib/reducers/Reducer.ts @@ -5,6 +5,7 @@ export const SearchReducer = (state: SearchState = SearchingInitialState, action case 'SET_FIND': return { ...state, + searchResults: null, find: action.payload, timeStamp: Date.now() } @@ -64,6 +65,21 @@ export const SearchReducer = (state: SearchState = SearchingInitialState, action ...state, } } + case 'CLEAR_STATS': + return { + ...state, + count: 0, + fileCount: 0, + searchResults: null, + searching: null + } + + case 'SET_SEARCHING': + return { + ...state, + searching: action.payload, + } + case 'CLEAR_UNDO': { state.undoBuffer = [] return { @@ -81,12 +97,7 @@ export const SearchReducer = (state: SearchState = SearchingInitialState, action } state.searchResults.forEach(file => { if (file.count) { - if(file.count > state.maxLines) { - clipped = true - count += state.maxLines - }else{ - count += file.count - } + count += file.count fileCount++ } }) @@ -99,6 +110,13 @@ export const SearchReducer = (state: SearchState = SearchingInitialState, action } else { return state } + + case 'SET_CLIPPED': + return { + ...state, + clipped: action.payload + } + case 'TOGGLE_CASE_SENSITIVE': return { ...state, diff --git a/libs/remix-ui/search/src/lib/search.css b/libs/remix-ui/search/src/lib/search.css index acc789d51c..6e4a21ef89 100644 --- a/libs/remix-ui/search/src/lib/search.css +++ b/libs/remix-ui/search/src/lib/search.css @@ -133,4 +133,9 @@ white-space: pre; text-overflow: ellipsis; overflow: hidden; +} +.search_plugin_search_indicator{ + white-space: pre; + text-overflow: ellipsis; + overflow: hidden; } \ No newline at end of file diff --git a/libs/remix-ui/search/src/lib/types/index.ts b/libs/remix-ui/search/src/lib/types/index.ts index 231c4ebf93..3e32c6a974 100644 --- a/libs/remix-ui/search/src/lib/types/index.ts +++ b/libs/remix-ui/search/src/lib/types/index.ts @@ -63,7 +63,8 @@ export interface SearchState { clipped: boolean, undoBuffer: Record[], currentFile: string, - workspace: string + workspace: string, + searching: string | null, } export const SearchingInitialState: SearchState = { @@ -85,5 +86,6 @@ export const SearchingInitialState: SearchState = { clipped: false, undoBuffer: null, currentFile: '', - workspace: '' + workspace: '', + searching: null } \ No newline at end of file From 8462bab4c05b587db3045bdc5ac76c9041755cba Mon Sep 17 00:00:00 2001 From: filip mertens Date: Thu, 17 Mar 2022 10:50:55 +0100 Subject: [PATCH 04/14] enable --- apps/remix-ide-e2e/src/tests/search.test.ts | 1 - apps/remix-ide/src/app.js | 6 ++++-- apps/remix-ide/src/remixAppManager.js | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/apps/remix-ide-e2e/src/tests/search.test.ts b/apps/remix-ide-e2e/src/tests/search.test.ts index 107a6ec9ef..6efcedd8ef 100644 --- a/apps/remix-ide-e2e/src/tests/search.test.ts +++ b/apps/remix-ide-e2e/src/tests/search.test.ts @@ -4,7 +4,6 @@ import { NightwatchBrowser } from 'nightwatch' import init from '../helpers/init' module.exports = { - '@disabled': true, before: function (browser: NightwatchBrowser, done: VoidFunction) { init(browser, done, 'http://127.0.0.1:8080', true) }, diff --git a/apps/remix-ide/src/app.js b/apps/remix-ide/src/app.js index 8b9197f5d5..e268ef8dcd 100644 --- a/apps/remix-ide/src/app.js +++ b/apps/remix-ide/src/app.js @@ -33,6 +33,7 @@ const isElectron = require('is-electron') const remixLib = require('@remix-project/remix-lib') import { QueryParams } from '@remix-project/remix-lib' +import { SearchPlugin } from './app/tabs/search' const Storage = remixLib.Storage const RemixDProvider = require('./app/files/remixDProvider') @@ -152,7 +153,7 @@ class AppComponent { const storagePlugin = new StoragePlugin() //----- search - // const search = new SearchPlugin() + const search = new SearchPlugin() // ----------------- import content service ------------------------ const contentImport = new CompilerImports() @@ -233,6 +234,7 @@ class AppComponent { hardhatProvider, ganacheProvider, this.walkthroughService, + search ]) // LAYOUT & SYSTEM VIEWS @@ -350,7 +352,7 @@ class AppComponent { await this.appManager.activatePlugin(['settings', 'config']) await this.appManager.activatePlugin(['hiddenPanel', 'pluginManager', 'contextualListener', 'terminal', 'blockchain', 'fetchAndCompile', 'contentImport', 'gistHandler']) await this.appManager.activatePlugin(['settings']) - await this.appManager.activatePlugin(['walkthrough','storage', 'intelligentScriptExecutor']) + await this.appManager.activatePlugin(['walkthrough','storage', 'search','intelligentScriptExecutor']) this.appManager.on( 'filePanel', diff --git a/apps/remix-ide/src/remixAppManager.js b/apps/remix-ide/src/remixAppManager.js index 0313d1baaa..8a75a094f9 100644 --- a/apps/remix-ide/src/remixAppManager.js +++ b/apps/remix-ide/src/remixAppManager.js @@ -8,7 +8,7 @@ const requiredModules = [ // services + layout views + system views 'manager', 'config', 'compilerArtefacts', 'compilerMetadata', 'contextualListener', 'editor', 'offsetToLineColumnConverter', 'network', 'theme', 'fileManager', 'contentImport', 'blockchain', 'web3Provider', 'scriptRunner', 'fetchAndCompile', 'mainPanel', 'hiddenPanel', 'sidePanel', 'menuicons', 'filePanel', 'terminal', 'settings', 'pluginManager', 'tabs', 'udapp', 'dGitProvider', 'solidity-logic', 'gistHandler', 'layout', - 'notification', 'permissionhandler', 'walkthrough', 'storage', 'restorebackupzip', 'link-libraries', 'deploy-libraries', 'hardhat-provider', 'intelligentScriptExecutor'] + 'notification', 'permissionhandler', 'walkthrough', 'storage', 'restorebackupzip', 'link-libraries', 'deploy-libraries', 'hardhat-provider', 'intelligentScriptExecutor', 'search'] const dependentModules = ['git', 'hardhat', 'truffle', 'slither'] // module which shouldn't be manually activated (e.g git is activated by remixd) From 905bf146c0fddd1646e1b5b607cf5498d2771c22 Mon Sep 17 00:00:00 2001 From: filip mertens Date: Thu, 17 Mar 2022 12:21:30 +0100 Subject: [PATCH 05/14] lint --- libs/remix-ui/search/src/lib/reducers/Reducer.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/remix-ui/search/src/lib/reducers/Reducer.ts b/libs/remix-ui/search/src/lib/reducers/Reducer.ts index 1455dab61e..101dde3221 100644 --- a/libs/remix-ui/search/src/lib/reducers/Reducer.ts +++ b/libs/remix-ui/search/src/lib/reducers/Reducer.ts @@ -91,7 +91,7 @@ export const SearchReducer = (state: SearchState = SearchingInitialState, action const findFile = state.searchResults.find(file => file.filename === action.payload.file) let count = 0 let fileCount = 0 - let clipped = false + const clipped = false if (findFile) { findFile.count = action.payload.count } From 0bb6a3cfb4d0330477495894acda3936113c07f7 Mon Sep 17 00:00:00 2001 From: filip mertens Date: Thu, 17 Mar 2022 13:22:24 +0100 Subject: [PATCH 06/14] stop button --- .../search/src/lib/components/Exclude.tsx | 13 +++++--- .../search/src/lib/components/Find.tsx | 31 +++++++++++-------- .../search/src/lib/components/Include.tsx | 19 ++++++++---- .../search/src/lib/components/Search.tsx | 1 - .../{CancelSearch.tsx => StopSearch.tsx} | 6 ++-- .../src/lib/components/results/ResultItem.tsx | 13 ++++++++ .../src/lib/components/results/Results.tsx | 8 +++-- .../search/src/lib/context/context.tsx | 18 ++++++++--- .../search/src/lib/reducers/Reducer.ts | 9 ++++-- libs/remix-ui/search/src/lib/search.css | 3 ++ libs/remix-ui/search/src/lib/types/index.ts | 4 ++- 11 files changed, 88 insertions(+), 37 deletions(-) rename libs/remix-ui/search/src/lib/components/{CancelSearch.tsx => StopSearch.tsx} (56%) diff --git a/libs/remix-ui/search/src/lib/components/Exclude.tsx b/libs/remix-ui/search/src/lib/components/Exclude.tsx index cd9aaf07bc..1558c6b312 100644 --- a/libs/remix-ui/search/src/lib/components/Exclude.tsx +++ b/libs/remix-ui/search/src/lib/components/Exclude.tsx @@ -4,12 +4,16 @@ import { SearchContext } from '../context/context' export const Exclude = props => { const { setExclude, cancelSearch } = useContext(SearchContext) const [excludeInput, setExcludeInput] = useState('.*/**/*') - const timeOutId = useRef(null) + const change = async e => { setExcludeInput(e.target.value) - clearTimeout(timeOutId.current) await cancelSearch() - timeOutId.current = setTimeout(() => setExclude(e.target.value), 500) + } + + const handleKeypress = async e => { + if (e.charCode === 13 || e.keyCode === 13) { + await setExclude(excludeInput) + } } useEffect(() => { @@ -21,9 +25,10 @@ export const Exclude = props => {
change(e)} value={excludeInput} > diff --git a/libs/remix-ui/search/src/lib/components/Find.tsx b/libs/remix-ui/search/src/lib/components/Find.tsx index 845eed7c0c..c6f6162a56 100644 --- a/libs/remix-ui/search/src/lib/components/Find.tsx +++ b/libs/remix-ui/search/src/lib/components/Find.tsx @@ -10,33 +10,38 @@ export const Find = () => { toggleMatchWholeWord, toggleUseRegex } = useContext(SearchContext) - const timeOutId = useRef(null) - const [inputValue, setInputValue] = useState(""); - const change = async(e) => { + + const [inputValue, setInputValue] = useState('') + const change = async e => { setInputValue(e.target.value) - clearTimeout(timeOutId.current) await cancelSearch() - timeOutId.current = setTimeout(async () => await setFind(e.target.value), 500) } - useEffect(() =>{ + const handleKeypress = async e => { + if (e.charCode === 13 || e.keyCode === 13) { + await setFind(inputValue) + } + } + + useEffect(() => { setInputValue('') - },[state.workspace]) + }, [state.workspace]) return ( <>
await change(e)} + onChange={async e => await change(e)} + onKeyPress={handleKeypress} >
{ }} >
{ }} >
{ const { setInclude, cancelSearch } = useContext(SearchContext) - const [includeInput, setIncludeInput] = useState('') - const timeOutId = useRef(null) + const [includeInput, setIncludeInput] = useState('*.sol, *.js') const change = async e => { setIncludeInput(e.target.value) - clearTimeout(timeOutId.current) await cancelSearch() - timeOutId.current = setTimeout(() => setInclude(e.target.value), 500) } + const handleKeypress = async e => { + if (e.charCode === 13 || e.keyCode === 13) { + await setInclude(includeInput) + } + } + + useEffect(() => { + setInclude(includeInput) + }, []) return ( <> @@ -18,9 +24,10 @@ export const Include = props => { change(e)} + onKeyPress={handleKeypress} value={includeInput} >
diff --git a/libs/remix-ui/search/src/lib/components/Search.tsx b/libs/remix-ui/search/src/lib/components/Search.tsx index 3dee1711e8..385f6e4ff9 100644 --- a/libs/remix-ui/search/src/lib/components/Search.tsx +++ b/libs/remix-ui/search/src/lib/components/Search.tsx @@ -6,7 +6,6 @@ import { Include } from './Include' import { Exclude } from './Exclude' import { FindContainer } from './FindContainer' import { Undo } from './Undo' -import { CacncelSearch } from './CancelSearch' export const SearchTab = props => { diff --git a/libs/remix-ui/search/src/lib/components/CancelSearch.tsx b/libs/remix-ui/search/src/lib/components/StopSearch.tsx similarity index 56% rename from libs/remix-ui/search/src/lib/components/CancelSearch.tsx rename to libs/remix-ui/search/src/lib/components/StopSearch.tsx index 5461c5ebec..41e66cc110 100644 --- a/libs/remix-ui/search/src/lib/components/CancelSearch.tsx +++ b/libs/remix-ui/search/src/lib/components/StopSearch.tsx @@ -2,12 +2,12 @@ import React from "react" import { useContext } from "react" import { SearchContext } from "../context/context" -export const CacncelSearch = () => { +export const StopSearch = () => { const { cancelSearch } = useContext(SearchContext) const cancel = async () => { - await cancelSearch() + await cancelSearch(false) } return ( - await cancel()}>stop + await cancel()}>stop ) } \ No newline at end of file diff --git a/libs/remix-ui/search/src/lib/components/results/ResultItem.tsx b/libs/remix-ui/search/src/lib/components/results/ResultItem.tsx index 0c36c057a7..c451502b62 100644 --- a/libs/remix-ui/search/src/lib/components/results/ResultItem.tsx +++ b/libs/remix-ui/search/src/lib/components/results/ResultItem.tsx @@ -28,8 +28,10 @@ export const ResultItem = (props: ResultItemProps) => { useEffect(() => { if (props.file.forceReload) { + console.log('force reload') clearTimeout(reloadTimeOut.current) clearTimeout(loadTimeout.current) + subscribed.current = true reloadTimeOut.current = setTimeout(() => reload(), 1000) } }, [props.file.forceReload]) @@ -47,6 +49,16 @@ export const ResultItem = (props: ResultItemProps) => { } }, []) + useEffect((): any => { + if(!state.run){ + clearTimeout(reloadTimeOut.current) + clearTimeout(loadTimeout.current) + subscribed.current = false + } else { + subscribed.current = true + } + },[state.run]) + const confirmReplace = async () => { setLoading(true) try { @@ -65,6 +77,7 @@ export const ResultItem = (props: ResultItemProps) => { } const doLoad = () => { + if(!subscribed.current) return findText(props.file.filename).then(res => { if (subscribed.current) { setLines(res) diff --git a/libs/remix-ui/search/src/lib/components/results/Results.tsx b/libs/remix-ui/search/src/lib/components/results/Results.tsx index 4d16f05235..f7573bf3b5 100644 --- a/libs/remix-ui/search/src/lib/components/results/Results.tsx +++ b/libs/remix-ui/search/src/lib/components/results/Results.tsx @@ -1,5 +1,6 @@ import React, { useContext, useEffect } from 'react' import { SearchContext } from '../../context/context' +import { StopSearch } from '../StopSearch' import { ResultItem } from './ResultItem' export const Results = () => { @@ -7,11 +8,12 @@ export const Results = () => { return (
- {' '} - {state.searching && !state.clipped + {state.searching && !state.clipped ? : null} {state.searching && !state.clipped ? `searching in ${state.searching}` - : null} + : null}

+
+ {state.find && !state.clipped ? (
showing {state.count} results {state.fileCount} in files diff --git a/libs/remix-ui/search/src/lib/context/context.tsx b/libs/remix-ui/search/src/lib/context/context.tsx index a8d3a7fab0..aca4c03fca 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: () => Promise + cancelSearch: (clearResults?:boolean) => Promise } export const SearchContext = createContext(null) @@ -177,6 +177,13 @@ export const SearchProvider = ({ }) }, + setRun(value: boolean) { + dispatch({ + type: 'SET_RUN', + payload: value + }) + }, + findText: async (path: string) => { if (!plugin) return try { @@ -191,6 +198,7 @@ export const SearchProvider = ({ clearSearchingTimeout.current = setTimeout(() => value.setSearching(null), 500) return result } catch (e) { + console.log(e) value.setSearching(null) // do nothing } @@ -275,9 +283,10 @@ export const SearchProvider = ({ }) }, - cancelSearch: async () => { + cancelSearch: async (clearResults: boolean = true) => { plugin.cancel('fileManager') - value.clearStats() + if(clearResults) value.clearStats() + value.setRun(false) }, setClipped: (value: boolean) => { @@ -305,6 +314,7 @@ export const SearchProvider = ({ }) plugin.on('fileManager', 'fileAdded', async file => { setFiles(await getDirectory('/', plugin)) + await reloadStateForFile(file) }) plugin.on('fileManager', 'currentFileChanged', async file => { value.setCurrentFile(file) @@ -372,7 +382,7 @@ export const SearchProvider = ({ useEffect(() => { if(state.count>500) { value.setClipped(true) - value.cancelSearch() + value.cancelSearch(false) } }, [state.count]) diff --git a/libs/remix-ui/search/src/lib/reducers/Reducer.ts b/libs/remix-ui/search/src/lib/reducers/Reducer.ts index 101dde3221..bc8be15f3a 100644 --- a/libs/remix-ui/search/src/lib/reducers/Reducer.ts +++ b/libs/remix-ui/search/src/lib/reducers/Reducer.ts @@ -40,7 +40,8 @@ export const SearchReducer = (state: SearchState = SearchingInitialState, action return { ...state, searchResults: action.payload, - count: 0 + count: 0, + run: true } case 'SET_UNDO_ENABLED': if(state.undoBuffer[`${action.payload.workspace}/${action.payload.path}`]){ @@ -116,7 +117,11 @@ export const SearchReducer = (state: SearchState = SearchingInitialState, action ...state, clipped: action.payload } - + case 'SET_RUN': + return { + ...state, + run: action.payload + } case 'TOGGLE_CASE_SENSITIVE': return { ...state, diff --git a/libs/remix-ui/search/src/lib/search.css b/libs/remix-ui/search/src/lib/search.css index 6e4a21ef89..17b49ab14d 100644 --- a/libs/remix-ui/search/src/lib/search.css +++ b/libs/remix-ui/search/src/lib/search.css @@ -138,4 +138,7 @@ white-space: pre; text-overflow: ellipsis; overflow: hidden; +} +.search_plugin_stop{ + cursor: pointer; } \ No newline at end of file diff --git a/libs/remix-ui/search/src/lib/types/index.ts b/libs/remix-ui/search/src/lib/types/index.ts index 3e32c6a974..b59eb23deb 100644 --- a/libs/remix-ui/search/src/lib/types/index.ts +++ b/libs/remix-ui/search/src/lib/types/index.ts @@ -65,6 +65,7 @@ export interface SearchState { currentFile: string, workspace: string, searching: string | null, + run: boolean, } export const SearchingInitialState: SearchState = { @@ -87,5 +88,6 @@ export const SearchingInitialState: SearchState = { undoBuffer: null, currentFile: '', workspace: '', - searching: null + searching: null, + run: false, } \ No newline at end of file From fe2ab41f96841745dbda73e6f5ca3f25e0c022e0 Mon Sep 17 00:00:00 2001 From: filip mertens Date: Thu, 17 Mar 2022 15:23:04 +0100 Subject: [PATCH 07/14] timeout --- .../search/src/lib/components/results/ResultItem.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libs/remix-ui/search/src/lib/components/results/ResultItem.tsx b/libs/remix-ui/search/src/lib/components/results/ResultItem.tsx index c451502b62..eb12ac26b9 100644 --- a/libs/remix-ui/search/src/lib/components/results/ResultItem.tsx +++ b/libs/remix-ui/search/src/lib/components/results/ResultItem.tsx @@ -32,7 +32,7 @@ export const ResultItem = (props: ResultItemProps) => { clearTimeout(reloadTimeOut.current) clearTimeout(loadTimeout.current) subscribed.current = true - reloadTimeOut.current = setTimeout(() => reload(), 1000) + reloadTimeOut.current = setTimeout(() => reload(0), 1000) } }, [props.file.forceReload]) @@ -96,8 +96,8 @@ export const ResultItem = (props: ResultItemProps) => { }) } - const reload = () => { - loadTimeout.current = setTimeout(doLoad, 150 * props.index) + const reload = (time?: number) => { + loadTimeout.current = setTimeout(doLoad, 150 * (time | props.index)) } return ( From b1cd2ae3a16fbecbb20102e787fdcd044018cd37 Mon Sep 17 00:00:00 2001 From: filip mertens Date: Wed, 23 Mar 2022 09:24:56 +0100 Subject: [PATCH 08/14] type --- libs/remix-ui/search/src/lib/context/context.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/remix-ui/search/src/lib/context/context.tsx b/libs/remix-ui/search/src/lib/context/context.tsx index aca4c03fca..f309236ea2 100644 --- a/libs/remix-ui/search/src/lib/context/context.tsx +++ b/libs/remix-ui/search/src/lib/context/context.tsx @@ -283,7 +283,7 @@ export const SearchProvider = ({ }) }, - cancelSearch: async (clearResults: boolean = true) => { + cancelSearch: async (clearResults = true) => { plugin.cancel('fileManager') if(clearResults) value.clearStats() value.setRun(false) From ed097b7de42b7d88f0bfb44540e617a4006b2cd3 Mon Sep 17 00:00:00 2001 From: filip mertens Date: Wed, 23 Mar 2022 11:19:12 +0100 Subject: [PATCH 09/14] fix bugs & tests --- apps/remix-ide-e2e/src/tests/search.test.ts | 387 +++++++++--------- .../search/src/lib/components/Exclude.tsx | 15 +- .../search/src/lib/components/Find.tsx | 6 +- .../search/src/lib/components/Include.tsx | 7 +- .../search/src/lib/context/context.tsx | 8 + .../search/src/lib/reducers/Reducer.ts | 10 +- 6 files changed, 223 insertions(+), 210 deletions(-) diff --git a/apps/remix-ide-e2e/src/tests/search.test.ts b/apps/remix-ide-e2e/src/tests/search.test.ts index 6efcedd8ef..523ce16d74 100644 --- a/apps/remix-ide-e2e/src/tests/search.test.ts +++ b/apps/remix-ide-e2e/src/tests/search.test.ts @@ -9,229 +9,228 @@ module.exports = { }, 'Should find text': function (browser: NightwatchBrowser) { browser.waitForElementVisible('*[data-id="remixIdeSidePanel"]') - .click('*[plugin="search"]').waitForElementVisible('*[id="search_input"]') - .setValue('*[id="search_input"]', 'read').pause(1000) - .waitForElementContainsText('*[data-id="search_results"]', '3_BALLOT.SOL', 60000) - .waitForElementContainsText('*[data-id="search_results"]', 'contracts', 60000) - .waitForElementContainsText('*[data-id="search_results"]', 'README.TXT', 60000) - .waitForElementContainsText('*[data-id="search_results"]', 'file must') - .waitForElementContainsText('*[data-id="search_results"]', 'be compiled') - .waitForElementContainsText('*[data-id="search_results"]', 'that person al') - .waitForElementContainsText('*[data-id="search_results"]', 'sender.voted') - .waitForElementContainsText('*[data-id="search_results"]', 'read') - .elements('css selector','.search_plugin_search_line', (res) => { - Array.isArray(res.value) && browser.assert.equal(res.value.length, 6) - }) + .click('*[plugin="search"]').waitForElementVisible('*[id="search_input"]') + .waitForElementVisible('*[id="search_include"]') + .setValue('*[id="search_include"]', ', *.txt').pause(2000) + .setValue('*[id="search_input"]', 'read').sendKeys('*[id="search_input"]', browser.Keys.ENTER) + .pause(1000) + .waitForElementContainsText('*[data-id="search_results"]', '3_BALLOT.SOL', 60000) + .waitForElementContainsText('*[data-id="search_results"]', 'contracts', 60000) + .waitForElementContainsText('*[data-id="search_results"]', 'README.TXT', 60000) + .waitForElementContainsText('*[data-id="search_results"]', 'file must') + .waitForElementContainsText('*[data-id="search_results"]', 'be compiled') + .waitForElementContainsText('*[data-id="search_results"]', 'that person al') + .waitForElementContainsText('*[data-id="search_results"]', 'sender.voted') + .waitForElementContainsText('*[data-id="search_results"]', 'read') + .elements('css selector', '.search_plugin_search_line', (res) => { + Array.isArray(res.value) && browser.assert.equal(res.value.length, 6) + }) + }, + 'Should find text with exclude': function (browser: NightwatchBrowser) { + browser + .clearValue('*[id="search_input"]') + .setValue('*[id="search_input"]', 'contract').pause(1000) + .clearValue('*[id="search_include"]').pause(2000) + .setValue('*[id="search_include"]', '**').sendKeys('*[id="search_include"]', browser.Keys.ENTER).pause(4000) + .elements('css selector', '.search_plugin_search_line', (res) => { + Array.isArray(res.value) && browser.assert.equal(res.value.length, 45) + }) + .setValue('*[id="search_exclude"]', ',contracts/**').sendKeys('*[id="search_exclude"]', browser.Keys.ENTER).pause(4000) + .elements('css selector', '.search_plugin_search_line', (res) => { + Array.isArray(res.value) && browser.assert.equal(res.value.length, 40) + }) + .clearValue('*[id="search_include"]').setValue('*[id="search_include"]', '*.sol, *.js, *.txt') + .clearValue('*[id="search_exclude"]').setValue('*[id="search_exclude"]', '.*/**/*') }, 'Should find regex': function (browser: NightwatchBrowser) { browser - .waitForElementVisible('*[data-id="search_use_regex"]').click('*[data-id="search_use_regex"]') - .waitForElementVisible('*[id="search_input"]') - .clearValue('*[id="search_input"]') - .setValue('*[id="search_input"]', '^contract').pause(1000) - .waitForElementContainsText('*[data-id="search_results"]', '3_BALLOT.SOL', 60000) - .waitForElementContainsText('*[data-id="search_results"]', '2_OWNER.SOL', 60000) - .waitForElementContainsText('*[data-id="search_results"]', '1_STORAGE.SOL', 60000) - .waitForElementContainsText('*[data-id="search_results"]', 'BALLOT_TEST.SOL', 60000) - .waitForElementContainsText('*[data-id="search_results"]', 'tests', 60000) - .elements('css selector','.search_plugin_search_line', (res) => { - Array.isArray(res.value) && browser.assert.equal(res.value.length, 4) - }) + .waitForElementVisible('*[data-id="search_use_regex"]').click('*[data-id="search_use_regex"]') + .waitForElementVisible('*[id="search_input"]') + .clearValue('*[id="search_input"]') + .setValue('*[id="search_input"]', '^contract').sendKeys('*[id="search_input"]', browser.Keys.ENTER) + .waitForElementContainsText('*[data-id="search_results"]', '3_BALLOT.SOL', 60000) + .waitForElementContainsText('*[data-id="search_results"]', '2_OWNER.SOL', 60000) + .waitForElementContainsText('*[data-id="search_results"]', '1_STORAGE.SOL', 60000) + .waitForElementContainsText('*[data-id="search_results"]', '4_BALLOT_TEST.SOL', 60000) + .waitForElementContainsText('*[data-id="search_results"]', 'tests', 60000) + .elements('css selector', '.search_plugin_search_line', (res) => { + Array.isArray(res.value) && browser.assert.equal(res.value.length, 4) + }) }, 'Should find matchcase': function (browser: NightwatchBrowser) { browser - .waitForElementVisible('*[data-id="search_use_regex"]').click('*[data-id="search_use_regex"]') - .waitForElementVisible('*[data-id="search_case_sensitive"]').click('*[data-id="search_case_sensitive"]') - .elements('css selector','.search_plugin_search_line', (res) => { - Array.isArray(res.value) && browser.assert.equal(res.value.length, 0) - }) - .clearValue('*[id="search_input"]') - .setValue('*[id="search_input"]', 'Contract').pause(1000) - .elements('css selector','.search_plugin_search_line', (res) => { - Array.isArray(res.value) && browser.assert.equal(res.value.length, 9) - }) - .waitForElementContainsText('*[data-id="search_results"]', 'DEPLOY_ETHERS.JS', 60000) - .waitForElementContainsText('*[data-id="search_results"]', 'DEPLOY_WEB3.JS', 60000) - .waitForElementContainsText('*[data-id="search_results"]', 'STORAGE.TEST.JS', 60000) - .waitForElementContainsText('*[data-id="search_results"]', 'scripts', 60000) + .waitForElementVisible('*[data-id="search_use_regex"]').click('*[data-id="search_use_regex"]') + .waitForElementVisible('*[data-id="search_case_sensitive"]').click('*[data-id="search_case_sensitive"]').pause(4000) + .elements('css selector', '.search_plugin_search_line', (res) => { + Array.isArray(res.value) && browser.assert.equal(res.value.length, 0) + }) + .clearValue('*[id="search_input"]') + .setValue('*[id="search_input"]', 'Contract').sendKeys('*[id="search_input"]', browser.Keys.ENTER).pause(1000) + .elements('css selector', '.search_plugin_search_line', (res) => { + Array.isArray(res.value) && browser.assert.equal(res.value.length, 9) + }) + .waitForElementContainsText('*[data-id="search_results"]', 'DEPLOY_ETHERS.JS', 60000) + .waitForElementContainsText('*[data-id="search_results"]', 'DEPLOY_WEB3.JS', 60000) + .waitForElementContainsText('*[data-id="search_results"]', 'STORAGE.TEST.JS', 60000) + .waitForElementContainsText('*[data-id="search_results"]', 'scripts', 60000) }, 'Should find matchword': function (browser: NightwatchBrowser) { browser - .waitForElementVisible('*[data-id="search_case_sensitive"]').click('*[data-id="search_case_sensitive"]') - .waitForElementVisible('*[data-id="search_whole_word"]').click('*[data-id="search_whole_word"]') - .clearValue('*[id="search_input"]') - .setValue('*[id="search_input"]', 'contract').pause(1000) - .elements('css selector','.search_plugin_search_line', (res) => { - Array.isArray(res.value) && browser.assert.equal(res.value.length, 29) - }) + .waitForElementVisible('*[data-id="search_case_sensitive"]').click('*[data-id="search_case_sensitive"]') + .waitForElementVisible('*[data-id="search_whole_word"]').click('*[data-id="search_whole_word"]').pause(2000) + .clearValue('*[id="search_input"]') + .setValue('*[id="search_input"]', 'contract').sendKeys('*[id="search_input"]', browser.Keys.ENTER).pause(4000) + .elements('css selector', '.search_plugin_search_line', (res) => { + Array.isArray(res.value) && browser.assert.equal(res.value.length, 29) + }) }, 'Should replace text': function (browser: NightwatchBrowser) { browser - .waitForElementVisible('*[data-id="toggle_replace"]').click('*[data-id="toggle_replace"]') - .waitForElementVisible('*[id="search_replace"]') - .setValue('*[id="search_replace"]', 'replacing').pause(1000) - .waitForElementVisible('*[data-id="contracts/2_Owner.sol-30-71"]') - .moveToElement('*[data-id="contracts/2_Owner.sol-30-71"]', 10, 10) - .waitForElementVisible('*[data-id="replace-contracts/2_Owner.sol-30-71"]') - .click('*[data-id="replace-contracts/2_Owner.sol-30-71"]').pause(2000). - modalFooterOKClick('confirmreplace').pause(2000). - getEditorValue((content) => { - browser.assert.ok(content.includes('replacing deployer for a constructor'), 'should replace text ok') - }) + .waitForElementVisible('*[data-id="toggle_replace"]').click('*[data-id="toggle_replace"]') + .waitForElementVisible('*[id="search_replace"]') + .setValue('*[id="search_replace"]', 'replacing').pause(1000) + .waitForElementVisible('*[data-id="contracts/2_Owner.sol-30-71"]') + .moveToElement('*[data-id="contracts/2_Owner.sol-30-71"]', 10, 10) + .waitForElementVisible('*[data-id="replace-contracts/2_Owner.sol-30-71"]') + .click('*[data-id="replace-contracts/2_Owner.sol-30-71"]').pause(2000). + modalFooterOKClick('confirmreplace').pause(2000). + getEditorValue((content) => { + browser.assert.ok(content.includes('replacing deployer for a constructor'), 'should replace text ok') + }) }, 'Should replace text without confirmation': function (browser: NightwatchBrowser) { browser.click('*[data-id="confirm_replace_label"]').pause(500) - .clearValue('*[id="search_input"]') - .setValue('*[id="search_input"]', 'replacing').pause(1000) - .setValue('*[id="search_replace"]', '2').pause(1000) - .waitForElementVisible('*[data-id="contracts/2_Owner.sol-30-71"]') - .moveToElement('*[data-id="contracts/2_Owner.sol-30-71"]', 10, 10) - .waitForElementVisible('*[data-id="replace-contracts/2_Owner.sol-30-71"]') - .click('*[data-id="replace-contracts/2_Owner.sol-30-71"]').pause(2000). - getEditorValue((content) => { - browser.assert.ok(content.includes('replacing2 deployer for a constructor'), 'should replace text ok') - }) + .clearValue('*[id="search_input"]') + .setValue('*[id="search_input"]', 'replacing').sendKeys('*[id="search_input"]', browser.Keys.ENTER).pause(1000) + .setValue('*[id="search_replace"]', '2').pause(1000) + .waitForElementVisible('*[data-id="contracts/2_Owner.sol-30-71"]') + .moveToElement('*[data-id="contracts/2_Owner.sol-30-71"]', 10, 10) + .waitForElementVisible('*[data-id="replace-contracts/2_Owner.sol-30-71"]') + .click('*[data-id="replace-contracts/2_Owner.sol-30-71"]').pause(2000). + getEditorValue((content) => { + browser.assert.ok(content.includes('replacing2 deployer for a constructor'), 'should replace text ok') + }) }, 'Should replace all & undo': function (browser: NightwatchBrowser) { browser - .clearValue('*[id="search_input"]') - .setValue('*[id="search_input"]', 'storage') - .clearValue('*[id="search_replace"]') - .setValue('*[id="search_replace"]', '123test').pause(1000) - .waitForElementVisible('*[data-id="replace-all-contracts/1_Storage.sol"]') - .click('*[data-id="replace-all-contracts/1_Storage.sol"]').pause(2000) - .getEditorValue((content) => { - browser.assert.ok(content.includes('contract 123test'), 'should replace text ok') - browser.assert.ok(content.includes('title 123test'), 'should replace text ok') - }) - .waitForElementVisible('*[data-id="undo-replace-contracts/1_Storage.sol"]') - .click('*[data-id="undo-replace-contracts/1_Storage.sol"]').pause(2000) - .getEditorValue((content) => { - browser.assert.ok(content.includes('contract Storage'), 'should undo text ok') - browser.assert.ok(content.includes('title Storage'), 'should undo text ok') - }) + .clearValue('*[id="search_input"]') + .setValue('*[id="search_input"]', 'storage').sendKeys('*[id="search_input"]', browser.Keys.ENTER) + .clearValue('*[id="search_replace"]') + .setValue('*[id="search_replace"]', '123test').pause(1000) + .waitForElementVisible('*[data-id="replace-all-contracts/1_Storage.sol"]') + .click('*[data-id="replace-all-contracts/1_Storage.sol"]').pause(2000) + .getEditorValue((content) => { + browser.assert.ok(content.includes('contract 123test'), 'should replace text ok') + browser.assert.ok(content.includes('title 123test'), 'should replace text ok') + }) + .waitForElementVisible('*[data-id="undo-replace-contracts/1_Storage.sol"]') + .click('*[data-id="undo-replace-contracts/1_Storage.sol"]').pause(2000) + .getEditorValue((content) => { + browser.assert.ok(content.includes('contract Storage'), 'should undo text ok') + browser.assert.ok(content.includes('title Storage'), 'should undo text ok') + }) }, 'Should replace all & undo & switch between files': function (browser: NightwatchBrowser) { browser.waitForElementVisible('*[id="search_input"]') - .clearValue('*[id="search_input"]') - .setValue('*[id="search_input"]', 'storage') - .clearValue('*[id="search_replace"]') - .setValue('*[id="search_replace"]', '123test').pause(1000) - .waitForElementVisible('*[data-id="replace-all-contracts/1_Storage.sol"]') - .click('*[data-id="replace-all-contracts/1_Storage.sol"]').pause(2000) - .getEditorValue((content) => { - browser.assert.ok(content.includes('contract 123test'), 'should replace text ok') - browser.assert.ok(content.includes('title 123test'), 'should replace text ok') - }) - .waitForElementVisible('*[data-id="undo-replace-contracts/1_Storage.sol"]') - .openFile('README.txt') - .click('*[plugin="search"]').pause(2000) - .waitForElementNotPresent('*[data-id="undo-replace-contracts/1_Storage.sol"]') - .waitForElementVisible('*[data-id="replace-all-README.txt"]') - .click('*[data-id="replace-all-README.txt"]').pause(2000) - .getEditorValue((content) => { - browser.assert.ok(content.includes("123test' contract"), 'should replace text ok') - }) - .waitForElementVisible('*[data-id="undo-replace-README.txt"]') - .click('div[title="default_workspace/contracts/1_Storage.sol"]').pause(2000) - .waitForElementVisible('*[data-id="undo-replace-contracts/1_Storage.sol"]') - .click('*[data-id="undo-replace-contracts/1_Storage.sol"]').pause(2000) - .getEditorValue((content) => { - browser.assert.ok(content.includes('contract Storage'), 'should undo text ok') - browser.assert.ok(content.includes('title Storage'), 'should undo text ok') - }) - .click('div[title="default_workspace/README.txt"]').pause(2000) - .waitForElementVisible('*[data-id="undo-replace-README.txt"]') - .click('*[data-id="undo-replace-README.txt"]').pause(2000) - .getEditorValue((content) => { - browser.assert.ok(content.includes("Storage' contract"), 'should replace text ok') - }) + .clearValue('*[id="search_input"]') + .setValue('*[id="search_input"]', 'storage').sendKeys('*[id="search_input"]', browser.Keys.ENTER) + .clearValue('*[id="search_replace"]') + .setValue('*[id="search_replace"]', '123test').pause(1000) + .waitForElementVisible('*[data-id="replace-all-contracts/1_Storage.sol"]') + .click('*[data-id="replace-all-contracts/1_Storage.sol"]').pause(2000) + .getEditorValue((content) => { + browser.assert.ok(content.includes('contract 123test'), 'should replace text ok') + browser.assert.ok(content.includes('title 123test'), 'should replace text ok') + }) + .waitForElementVisible('*[data-id="undo-replace-contracts/1_Storage.sol"]') + .openFile('README.txt') + .click('*[plugin="search"]').pause(2000) + .waitForElementNotPresent('*[data-id="undo-replace-contracts/1_Storage.sol"]') + .waitForElementVisible('*[data-id="replace-all-README.txt"]') + .click('*[data-id="replace-all-README.txt"]').pause(2000) + .getEditorValue((content) => { + browser.assert.ok(content.includes("123test' contract"), 'should replace text ok') + }) + .waitForElementVisible('*[data-id="undo-replace-README.txt"]') + .click('div[title="default_workspace/contracts/1_Storage.sol"]').pause(2000) + .waitForElementVisible('*[data-id="undo-replace-contracts/1_Storage.sol"]') + .click('*[data-id="undo-replace-contracts/1_Storage.sol"]').pause(2000) + .getEditorValue((content) => { + browser.assert.ok(content.includes('contract Storage'), 'should undo text ok') + browser.assert.ok(content.includes('title Storage'), 'should undo text ok') + }) + .click('div[title="default_workspace/README.txt"]').pause(2000) + .waitForElementVisible('*[data-id="undo-replace-README.txt"]') + .click('*[data-id="undo-replace-README.txt"]').pause(2000) + .getEditorValue((content) => { + browser.assert.ok(content.includes("Storage' contract"), 'should replace text ok') + }) }, 'Should hide button when edited content is the same': function (browser: NightwatchBrowser) { browser.waitForElementVisible('*[data-id="remixIdeSidePanel"]') - .addFile('test.sol', { content: '123'}) - .click('*[plugin="search"]').waitForElementVisible('*[id="search_input"]') - .clearValue('*[id="search_input"]') - .setValue('*[id="search_input"]', '123') - .clearValue('*[id="search_replace"]') - .setValue('*[id="search_replace"]', '456').pause(1000) - .waitForElementVisible('*[data-id="replace-all-test.sol"]') - .click('*[data-id="replace-all-test.sol"]').pause(2000) - .getEditorValue((content) => { - browser.assert.ok(content.includes('456'), 'should replace text ok') - } - ) - .setEditorValue('123') - .getEditorValue((content) => { - browser.assert.ok(content.includes('123'), 'should have text ok') - } - ).pause(1000) - .waitForElementNotPresent('*[data-id="undo-replace-test.sol"]') + .addFile('test.sol', { content: '123' }) + .click('*[plugin="search"]').waitForElementVisible('*[id="search_input"]') + .clearValue('*[id="search_input"]') + .setValue('*[id="search_input"]', '123').sendKeys('*[id="search_input"]', browser.Keys.ENTER) + .clearValue('*[id="search_replace"]') + .setValue('*[id="search_replace"]', '456').pause(1000) + .waitForElementVisible('*[data-id="replace-all-test.sol"]') + .click('*[data-id="replace-all-test.sol"]').pause(2000) + .getEditorValue((content) => { + browser.assert.ok(content.includes('456'), 'should replace text ok') + } + ) + .setEditorValue('123') + .getEditorValue((content) => { + browser.assert.ok(content.includes('123'), 'should have text ok') + } + ).pause(1000) + .waitForElementNotPresent('*[data-id="undo-replace-test.sol"]') }, 'Should disable/enable button when edited content changed': function (browser: NightwatchBrowser) { browser - .waitForElementVisible('*[id="search_input"]') - .clearValue('*[id="search_input"]') - .setValue('*[id="search_input"]', '123') - .clearValue('*[id="search_replace"]') - .setValue('*[id="search_replace"]', 'replaced').pause(1000) - .waitForElementVisible('*[data-id="replace-all-test.sol"]') - .click('*[data-id="replace-all-test.sol"]').pause(2000) - .getEditorValue((content) => { - browser.assert.ok(content.includes('replaced'), 'should replace text ok') - } - ) - .setEditorValue('changed') - .getEditorValue((content) => { - browser.assert.ok(content.includes('changed'), 'should have text ok') - } - ).pause(1000) - .waitForElementVisible('*[data-id="undo-replace-test.sol"]') - .getAttribute('[data-id="undo-replace-test.sol"]', 'disabled', (result) => { - browser.assert.equal(result.value, 'true', 'should be disabled') - }) - .setEditorValue('replaced') - .getEditorValue((content) => { - browser.assert.ok(content.includes('replaced'), 'should have text ok') - } - ).pause(1000) - .waitForElementVisible('*[data-id="undo-replace-test.sol"]') - .getAttribute('[data-id="undo-replace-test.sol"]', 'disabled', (result) => { - browser.assert.equal(result.value, null, 'should not be disabled') - }) - .click('*[data-id="undo-replace-test.sol"]').pause(2000) - .getEditorValue((content) => { - browser.assert.ok(content.includes('123'), 'should have text ok') - }) - .waitForElementNotPresent('*[data-id="undo-replace-test.sol"]') - }, - 'Should find text with include': function (browser: NightwatchBrowser) { - browser - .clearValue('*[id="search_input"]') - .setValue('*[id="search_input"]', 'contract').pause(1000) - .setValue('*[id="search_include"]', 'contracts/**').pause(2000) - .elements('css selector','.search_plugin_search_line', (res) => { - Array.isArray(res.value) && browser.assert.equal(res.value.length, 4) - }) - }, - 'Should find text with exclude': function (browser: NightwatchBrowser) { - browser - .clearValue('*[id="search_include"]').pause(2000) - .setValue('*[id="search_include"]', '**').pause(2000) - .elements('css selector','.search_plugin_search_line', (res) => { - Array.isArray(res.value) && browser.assert.equal(res.value.length, 28) - }) - .setValue('*[id="search_exclude"]', ',contracts/**').pause(2000) - .elements('css selector','.search_plugin_search_line', (res) => { - Array.isArray(res.value) && browser.assert.equal(res.value.length, 24) - }) + .waitForElementVisible('*[id="search_input"]') + .clearValue('*[id="search_input"]') + .setValue('*[id="search_input"]', '123').sendKeys('*[id="search_input"]', browser.Keys.ENTER) + .clearValue('*[id="search_replace"]') + .setValue('*[id="search_replace"]', 'replaced').pause(1000) + .waitForElementVisible('*[data-id="replace-all-test.sol"]') + .click('*[data-id="replace-all-test.sol"]').pause(2000) + .getEditorValue((content) => { + browser.assert.ok(content.includes('replaced'), 'should replace text ok') + } + ) + .setEditorValue('changed') + .getEditorValue((content) => { + browser.assert.ok(content.includes('changed'), 'should have text ok') + } + ).pause(1000) + .waitForElementVisible('*[data-id="undo-replace-test.sol"]') + .getAttribute('[data-id="undo-replace-test.sol"]', 'disabled', (result) => { + browser.assert.equal(result.value, 'true', 'should be disabled') + }) + .setEditorValue('replaced') + .getEditorValue((content) => { + browser.assert.ok(content.includes('replaced'), 'should have text ok') + } + ).pause(1000) + .waitForElementVisible('*[data-id="undo-replace-test.sol"]') + .getAttribute('[data-id="undo-replace-test.sol"]', 'disabled', (result) => { + browser.assert.equal(result.value, null, 'should not be disabled') + }) + .click('*[data-id="undo-replace-test.sol"]').pause(2000) + .getEditorValue((content) => { + browser.assert.ok(content.includes('123'), 'should have text ok') + }) + .waitForElementNotPresent('*[data-id="undo-replace-test.sol"]') }, + 'should clear search': function (browser: NightwatchBrowser) { browser - .waitForElementVisible('*[id="search_input"]') - .setValue('*[id="search_input"]', 'nodata').pause(1000) - .elements('css selector','.search_plugin_search_line', (res) => { - Array.isArray(res.value) && browser.assert.equal(res.value.length, 0) - }) + .waitForElementVisible('*[id="search_input"]') + .setValue('*[id="search_input"]', 'nodata').sendKeys('*[id="search_input"]', browser.Keys.ENTER).pause(1000) + .elements('css selector', '.search_plugin_search_line', (res) => { + Array.isArray(res.value) && browser.assert.equal(res.value.length, 0) + }) } } \ No newline at end of file diff --git a/libs/remix-ui/search/src/lib/components/Exclude.tsx b/libs/remix-ui/search/src/lib/components/Exclude.tsx index 1558c6b312..ef1e41b18d 100644 --- a/libs/remix-ui/search/src/lib/components/Exclude.tsx +++ b/libs/remix-ui/search/src/lib/components/Exclude.tsx @@ -2,17 +2,18 @@ import React, { useContext, useEffect, useRef, useState } from 'react' import { SearchContext } from '../context/context' export const Exclude = props => { - const { setExclude, cancelSearch } = useContext(SearchContext) + const { setExclude, cancelSearch, startSearch } = useContext(SearchContext) const [excludeInput, setExcludeInput] = useState('.*/**/*') const change = async e => { setExcludeInput(e.target.value) await cancelSearch() } - + const handleKeypress = async e => { + await setExclude(excludeInput) if (e.charCode === 13 || e.keyCode === 13) { - await setExclude(excludeInput) + startSearch() } } @@ -25,11 +26,11 @@ export const Exclude = props => {
change(e)} + onKeyUp={handleKeypress} + onChange={async (e) => change(e)} value={excludeInput} >
diff --git a/libs/remix-ui/search/src/lib/components/Find.tsx b/libs/remix-ui/search/src/lib/components/Find.tsx index c6f6162a56..284a2d07ba 100644 --- a/libs/remix-ui/search/src/lib/components/Find.tsx +++ b/libs/remix-ui/search/src/lib/components/Find.tsx @@ -5,6 +5,7 @@ export const Find = () => { const { setFind, cancelSearch, + startSearch, state, toggleCaseSensitive, toggleMatchWholeWord, @@ -19,8 +20,9 @@ export const Find = () => { const handleKeypress = async e => { if (e.charCode === 13 || e.keyCode === 13) { - await setFind(inputValue) + startSearch() } + await setFind(inputValue) } useEffect(() => { @@ -37,7 +39,7 @@ export const Find = () => { className="form-control" value={inputValue} onChange={async e => await change(e)} - onKeyPress={handleKeypress} + onKeyUp={handleKeypress} >
{ - const { setInclude, cancelSearch } = useContext(SearchContext) + const { setInclude, cancelSearch, startSearch } = useContext(SearchContext) const [includeInput, setIncludeInput] = useState('*.sol, *.js') const change = async e => { setIncludeInput(e.target.value) await cancelSearch() } const handleKeypress = async e => { + await setInclude(includeInput) if (e.charCode === 13 || e.keyCode === 13) { - await setInclude(includeInput) + startSearch() } } @@ -27,7 +28,7 @@ export const Include = props => { placeholder="Include ie *.sol ( Enter to include )" className="form-control" onChange={async(e) => change(e)} - onKeyPress={handleKeypress} + onKeyUp={handleKeypress} value={includeInput} >
diff --git a/libs/remix-ui/search/src/lib/context/context.tsx b/libs/remix-ui/search/src/lib/context/context.tsx index f309236ea2..ea21e36171 100644 --- a/libs/remix-ui/search/src/lib/context/context.tsx +++ b/libs/remix-ui/search/src/lib/context/context.tsx @@ -46,6 +46,7 @@ export interface SearchingStateInterface { undoReplace: (buffer: undoBufferRecord) => Promise clearUndo: () => void cancelSearch: (clearResults?:boolean) => Promise + startSearch: () => void } export const SearchContext = createContext(null) @@ -177,6 +178,13 @@ export const SearchProvider = ({ }) }, + startSearch: () => { + dispatch({ + type: 'START_SEARCH', + payload: undefined + }) + }, + setRun(value: boolean) { dispatch({ type: 'SET_RUN', diff --git a/libs/remix-ui/search/src/lib/reducers/Reducer.ts b/libs/remix-ui/search/src/lib/reducers/Reducer.ts index bc8be15f3a..3e83b75aea 100644 --- a/libs/remix-ui/search/src/lib/reducers/Reducer.ts +++ b/libs/remix-ui/search/src/lib/reducers/Reducer.ts @@ -2,12 +2,16 @@ import { Action, SearchingInitialState, SearchState, undoBufferRecord } from ".. export const SearchReducer = (state: SearchState = SearchingInitialState, action: Action) => { switch (action.type) { + case 'START_SEARCH': + return { + ...state, + timeStamp: Date.now() + } case 'SET_FIND': return { ...state, searchResults: null, - find: action.payload, - timeStamp: Date.now() + find: action.payload } case 'SET_REPLACE': @@ -26,14 +30,12 @@ export const SearchReducer = (state: SearchState = SearchingInitialState, action return { ...state, include: action.payload, - timeStamp: Date.now() } case 'SET_EXCLUDE': return { ...state, exclude: action.payload, - timeStamp: Date.now() } case 'SET_SEARCH_RESULTS': From d1253efbdae691c4d117f175ba1a1a22a1d3a3ea Mon Sep 17 00:00:00 2001 From: bunsenstraat Date: Tue, 29 Mar 2022 11:13:32 +0200 Subject: [PATCH 10/14] bugs --- libs/remix-ui/search/src/lib/context/context.tsx | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/libs/remix-ui/search/src/lib/context/context.tsx b/libs/remix-ui/search/src/lib/context/context.tsx index ea21e36171..a719209a42 100644 --- a/libs/remix-ui/search/src/lib/context/context.tsx +++ b/libs/remix-ui/search/src/lib/context/context.tsx @@ -111,7 +111,7 @@ export const SearchProvider = ({ payload: value }) }, - setSearchResults(value: SearchResult[]) { + setSearchResults(value: SearchResult[]) { dispatch({ type: 'SET_SEARCH_RESULTS', payload: value @@ -285,6 +285,7 @@ export const SearchProvider = ({ }, clearStats: () => { + plugin.call('editor', 'discardHighlight') dispatch({ type: 'CLEAR_STATS', payload: undefined @@ -320,6 +321,12 @@ export const SearchProvider = ({ await reloadStateForFile(file) await checkUndoState(file) }) + plugin.on('fileManager', 'rootFolderChanged', async file => { + const workspace = await plugin.call('filePanel', 'getCurrentWorkspace') + if(workspace) value.setCurrentWorkspace(workspace.name) + setFiles(await getDirectory('/', plugin)) + }) + plugin.on('fileManager', 'fileAdded', async file => { setFiles(await getDirectory('/', plugin)) await reloadStateForFile(file) @@ -328,6 +335,13 @@ export const SearchProvider = ({ value.setCurrentFile(file) await checkUndoState(file) }) + async function fetchWorkspace() { + const workspace = await plugin.call('filePanel', 'getCurrentWorkspace') + if(workspace) value.setCurrentWorkspace(workspace.name) + setFiles(await getDirectory('/', plugin)) + } + + fetchWorkspace() return () => { plugin.off('fileManager', 'fileChanged') From a091742c3c707c6400a2e60a682a5651d7ac4214 Mon Sep 17 00:00:00 2001 From: bunsenstraat Date: Wed, 30 Mar 2022 07:50:28 +0200 Subject: [PATCH 11/14] update tests --- apps/remix-ide-e2e/src/tests/search.test.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/remix-ide-e2e/src/tests/search.test.ts b/apps/remix-ide-e2e/src/tests/search.test.ts index 523ce16d74..f2cee6ba1a 100644 --- a/apps/remix-ide-e2e/src/tests/search.test.ts +++ b/apps/remix-ide-e2e/src/tests/search.test.ts @@ -33,7 +33,7 @@ module.exports = { .clearValue('*[id="search_include"]').pause(2000) .setValue('*[id="search_include"]', '**').sendKeys('*[id="search_include"]', browser.Keys.ENTER).pause(4000) .elements('css selector', '.search_plugin_search_line', (res) => { - Array.isArray(res.value) && browser.assert.equal(res.value.length, 45) + Array.isArray(res.value) && browser.assert.equal(res.value.length, 46) }) .setValue('*[id="search_exclude"]', ',contracts/**').sendKeys('*[id="search_exclude"]', browser.Keys.ENTER).pause(4000) .elements('css selector', '.search_plugin_search_line', (res) => { @@ -51,7 +51,7 @@ module.exports = { .waitForElementContainsText('*[data-id="search_results"]', '3_BALLOT.SOL', 60000) .waitForElementContainsText('*[data-id="search_results"]', '2_OWNER.SOL', 60000) .waitForElementContainsText('*[data-id="search_results"]', '1_STORAGE.SOL', 60000) - .waitForElementContainsText('*[data-id="search_results"]', '4_BALLOT_TEST.SOL', 60000) + .waitForElementContainsText('*[data-id="search_results"]', 'BALLOT_TEST.SOL', 60000) .waitForElementContainsText('*[data-id="search_results"]', 'tests', 60000) .elements('css selector', '.search_plugin_search_line', (res) => { Array.isArray(res.value) && browser.assert.equal(res.value.length, 4) @@ -81,7 +81,7 @@ module.exports = { .clearValue('*[id="search_input"]') .setValue('*[id="search_input"]', 'contract').sendKeys('*[id="search_input"]', browser.Keys.ENTER).pause(4000) .elements('css selector', '.search_plugin_search_line', (res) => { - Array.isArray(res.value) && browser.assert.equal(res.value.length, 29) + Array.isArray(res.value) && browser.assert.equal(res.value.length, 30) }) }, 'Should replace text': function (browser: NightwatchBrowser) { From 7ec8bfef201395fdbbbc36aa7cad7e481966bb99 Mon Sep 17 00:00:00 2001 From: filip mertens Date: Wed, 30 Mar 2022 08:26:49 +0200 Subject: [PATCH 12/14] update tests --- apps/remix-ide-e2e/src/tests/search.test.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/apps/remix-ide-e2e/src/tests/search.test.ts b/apps/remix-ide-e2e/src/tests/search.test.ts index f2cee6ba1a..b7c63cb6a0 100644 --- a/apps/remix-ide-e2e/src/tests/search.test.ts +++ b/apps/remix-ide-e2e/src/tests/search.test.ts @@ -88,11 +88,11 @@ module.exports = { browser .waitForElementVisible('*[data-id="toggle_replace"]').click('*[data-id="toggle_replace"]') .waitForElementVisible('*[id="search_replace"]') - .setValue('*[id="search_replace"]', 'replacing').pause(1000) - .waitForElementVisible('*[data-id="contracts/2_Owner.sol-30-71"]') - .moveToElement('*[data-id="contracts/2_Owner.sol-30-71"]', 10, 10) - .waitForElementVisible('*[data-id="replace-contracts/2_Owner.sol-30-71"]') - .click('*[data-id="replace-contracts/2_Owner.sol-30-71"]').pause(2000). + .setValue('*[id="search_replace"]', 'replacing').sendKeys('*[id="search_replace"]', browser.Keys.ENTER).pause(1000) + .waitForElementVisible('*[data-id="contracts/2_Owner.sol-33-71"]') + .moveToElement('*[data-id="contracts/2_Owner.sol-33-71"]', 10, 10) + .waitForElementVisible('*[data-id="replace-contracts/2_Owner.sol-33-71"]') + .click('*[data-id="replace-contracts/2_Owner.sol-33-71"]').pause(2000). modalFooterOKClick('confirmreplace').pause(2000). getEditorValue((content) => { browser.assert.ok(content.includes('replacing deployer for a constructor'), 'should replace text ok') @@ -103,10 +103,10 @@ module.exports = { .clearValue('*[id="search_input"]') .setValue('*[id="search_input"]', 'replacing').sendKeys('*[id="search_input"]', browser.Keys.ENTER).pause(1000) .setValue('*[id="search_replace"]', '2').pause(1000) - .waitForElementVisible('*[data-id="contracts/2_Owner.sol-30-71"]') - .moveToElement('*[data-id="contracts/2_Owner.sol-30-71"]', 10, 10) - .waitForElementVisible('*[data-id="replace-contracts/2_Owner.sol-30-71"]') - .click('*[data-id="replace-contracts/2_Owner.sol-30-71"]').pause(2000). + .waitForElementVisible('*[data-id="contracts/2_Owner.sol-33-71"]') + .moveToElement('*[data-id="contracts/2_Owner.sol-33-71"]', 10, 10) + .waitForElementVisible('*[data-id="replace-contracts/2_Owner.sol-33-71"]') + .click('*[data-id="replace-contracts/2_Owner.sol-33-71"]').pause(2000). getEditorValue((content) => { browser.assert.ok(content.includes('replacing2 deployer for a constructor'), 'should replace text ok') }) From cf4efbdfa2b3429f89fb687a595e5eb1ae5ef295 Mon Sep 17 00:00:00 2001 From: filip mertens Date: Wed, 30 Mar 2022 09:14:17 +0200 Subject: [PATCH 13/14] update tests --- apps/remix-ide-e2e/src/tests/search.test.ts | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/apps/remix-ide-e2e/src/tests/search.test.ts b/apps/remix-ide-e2e/src/tests/search.test.ts index b7c63cb6a0..7903e56abe 100644 --- a/apps/remix-ide-e2e/src/tests/search.test.ts +++ b/apps/remix-ide-e2e/src/tests/search.test.ts @@ -33,11 +33,11 @@ module.exports = { .clearValue('*[id="search_include"]').pause(2000) .setValue('*[id="search_include"]', '**').sendKeys('*[id="search_include"]', browser.Keys.ENTER).pause(4000) .elements('css selector', '.search_plugin_search_line', (res) => { - Array.isArray(res.value) && browser.assert.equal(res.value.length, 46) + Array.isArray(res.value) && browser.assert.equal(res.value.length, 44) }) .setValue('*[id="search_exclude"]', ',contracts/**').sendKeys('*[id="search_exclude"]', browser.Keys.ENTER).pause(4000) .elements('css selector', '.search_plugin_search_line', (res) => { - Array.isArray(res.value) && browser.assert.equal(res.value.length, 40) + Array.isArray(res.value) && browser.assert.equal(res.value.length, 38) }) .clearValue('*[id="search_include"]').setValue('*[id="search_include"]', '*.sol, *.js, *.txt') .clearValue('*[id="search_exclude"]').setValue('*[id="search_exclude"]', '.*/**/*') @@ -65,14 +65,11 @@ module.exports = { Array.isArray(res.value) && browser.assert.equal(res.value.length, 0) }) .clearValue('*[id="search_input"]') - .setValue('*[id="search_input"]', 'Contract').sendKeys('*[id="search_input"]', browser.Keys.ENTER).pause(1000) + .setValue('*[id="search_input"]', 'Contract').sendKeys('*[id="search_input"]', browser.Keys.ENTER).pause(3000) .elements('css selector', '.search_plugin_search_line', (res) => { - Array.isArray(res.value) && browser.assert.equal(res.value.length, 9) + Array.isArray(res.value) && browser.assert.equal(res.value.length, 3) }) - .waitForElementContainsText('*[data-id="search_results"]', 'DEPLOY_ETHERS.JS', 60000) - .waitForElementContainsText('*[data-id="search_results"]', 'DEPLOY_WEB3.JS', 60000) .waitForElementContainsText('*[data-id="search_results"]', 'STORAGE.TEST.JS', 60000) - .waitForElementContainsText('*[data-id="search_results"]', 'scripts', 60000) }, 'Should find matchword': function (browser: NightwatchBrowser) { browser @@ -81,7 +78,7 @@ module.exports = { .clearValue('*[id="search_input"]') .setValue('*[id="search_input"]', 'contract').sendKeys('*[id="search_input"]', browser.Keys.ENTER).pause(4000) .elements('css selector', '.search_plugin_search_line', (res) => { - Array.isArray(res.value) && browser.assert.equal(res.value.length, 30) + Array.isArray(res.value) && browser.assert.equal(res.value.length, 13) }) }, 'Should replace text': function (browser: NightwatchBrowser) { From 6b163d9f4591825429e081ac73666361d9f959d2 Mon Sep 17 00:00:00 2001 From: bunsenstraat Date: Tue, 5 Apr 2022 14:37:13 +0200 Subject: [PATCH 14/14] Update Search.tsx --- libs/remix-ui/search/src/lib/components/Search.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/remix-ui/search/src/lib/components/Search.tsx b/libs/remix-ui/search/src/lib/components/Search.tsx index 385f6e4ff9..8fa6053c34 100644 --- a/libs/remix-ui/search/src/lib/components/Search.tsx +++ b/libs/remix-ui/search/src/lib/components/Search.tsx @@ -13,7 +13,7 @@ export const SearchTab = props => { return ( <> -
+