🐛 fix minisearch warning
This commit is contained in:
parent
d9fe6ea644
commit
f480e9eb75
4 changed files with 26 additions and 30 deletions
|
|
@ -271,7 +271,7 @@ export async function getComputeDeleteAddRemove(
|
|||
removeTag.push({ path, cacheKey });
|
||||
} else {
|
||||
if (existingTags.length === 0) {
|
||||
console.warn("Existing tags should not be empty when trying to remove");
|
||||
// console.warn("Existing tags should not be empty when trying to remove");
|
||||
}
|
||||
|
||||
del.push({ path, cacheKey });
|
||||
|
|
|
|||
|
|
@ -67,6 +67,6 @@ export function startProxy() {
|
|||
console.log(`Proxy server is running on port ${PROXY_PORT}`);
|
||||
});
|
||||
server.on("error", (e) => {
|
||||
console.log("Proxy server already running on port 65433");
|
||||
// console.log("Proxy server already running on port 65433");
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { createContext, useEffect, useState } from "react";
|
||||
import { createContext, useState } from "react";
|
||||
import { useDispatch } from "react-redux";
|
||||
import { RouterProvider, createMemoryRouter } from "react-router-dom";
|
||||
import Layout from "./components/Layout";
|
||||
|
|
@ -83,6 +83,22 @@ export const FoldersSearchContext = createContext<
|
|||
[MiniSearch, MiniSearchResult[]]
|
||||
>([foldersMiniSearch, []]);
|
||||
|
||||
(async () => {
|
||||
const files = await new ExtensionIde().listWorkspaceContents();
|
||||
const results = files.map((filepath) => {
|
||||
return { id: filepath, basename: getBasename(filepath) };
|
||||
});
|
||||
filesMiniSearch.addAll(results);
|
||||
})();
|
||||
|
||||
(async () => {
|
||||
const folders = await new ExtensionIde().listFolders();
|
||||
const results = folders.map((path) => {
|
||||
return { id: path, basename: getBasename(path) };
|
||||
});
|
||||
foldersMiniSearch.addAll(results);
|
||||
})();
|
||||
|
||||
export interface MiniSearchResult {
|
||||
id: string;
|
||||
basename: string;
|
||||
|
|
@ -93,39 +109,19 @@ function App() {
|
|||
|
||||
useSetup(dispatch);
|
||||
|
||||
const [filesFirstResults, setFilesFirstResults] = useState<
|
||||
const [filesFirstResultsState, setFilesFirstResults] = useState<
|
||||
MiniSearchResult[]
|
||||
>([]);
|
||||
const [foldersFirstResults, setFoldersFirstResults] = useState<
|
||||
const [foldersFirstResultsState, setFoldersFirstResults] = useState<
|
||||
MiniSearchResult[]
|
||||
>([]);
|
||||
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
const files = await new ExtensionIde().listWorkspaceContents();
|
||||
const results = files.map((filepath) => {
|
||||
return { id: filepath, basename: getBasename(filepath) };
|
||||
});
|
||||
filesMiniSearch.addAll(results);
|
||||
setFilesFirstResults(results);
|
||||
})();
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
const folders = await new ExtensionIde().listFolders();
|
||||
const results = folders.map((path) => {
|
||||
return { id: path, basename: getBasename(path) };
|
||||
});
|
||||
foldersMiniSearch.addAll(results);
|
||||
setFoldersFirstResults(results);
|
||||
})();
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<FilesSearchContext.Provider value={[filesMiniSearch, filesFirstResults]}>
|
||||
<FilesSearchContext.Provider
|
||||
value={[filesMiniSearch, filesFirstResultsState]}
|
||||
>
|
||||
<FoldersSearchContext.Provider
|
||||
value={[foldersMiniSearch, foldersFirstResults]}
|
||||
value={[foldersMiniSearch, foldersFirstResultsState]}
|
||||
>
|
||||
<RouterProvider router={router} />
|
||||
</FoldersSearchContext.Provider>
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ function getFileItems(
|
|||
): ComboBoxItem[] {
|
||||
let res: any[] = miniSearch.search(query.trim() === "" ? "/" : query, {
|
||||
prefix: true,
|
||||
fuzzy: 5,
|
||||
fuzzy: 4,
|
||||
});
|
||||
if (res.length === 0) {
|
||||
return openFiles.length > 0 ? openFiles : firstResults;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue