MCPcopy Create free account
hub / github.com/Acode-Foundation/Acode / findFile

Function findFile

src/palettes/findFile/index.js:14–50  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

12let hintsModification;
13
14export default async function findFile() {
15 palette(generateHints, onselect, strings["type filename"], () => {
16 files.off("add-file", onAddFile);
17 files.off("remove-file", onRemoveFile);
18 });
19
20 files.on("add-file", onAddFile);
21 files.on("remove-file", onRemoveFile);
22
23 /**
24 * Generates hint for inputhints
25 * @param {HintModification} hints Hint modification object
26 */
27 async function generateHints(hints) {
28 hintsModification = hints;
29 const list = [];
30
31 editorManager.files.forEach((file) => {
32 const { uri, name } = file;
33 let { location = "" } = file;
34
35 if (location) {
36 location = helpers.getVirtualPath(location);
37 }
38
39 list.push(hintItem(name, location, uri));
40 });
41
42 list.push(...files(hintItem));
43 return list;
44 }
45
46 function onselect(value) {
47 if (!value) return;
48 openFile(value);
49 }
50}
51
52/**
53 * Generates hint item for inputhints

Callers 1

"find-file"Function · 0.85

Calls 3

paletteFunction · 0.85
offMethod · 0.80
onMethod · 0.45

Tested by

no test coverage detected