Skip to content

Commit aa31ba4

Browse files
committed
fix(path): fix select-anyway
1 parent 4ee804d commit aa31ba4

File tree

2 files changed

+22
-21
lines changed

2 files changed

+22
-21
lines changed

src/main/browse.ts

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -33,40 +33,41 @@ let selectedPath = await path({
3333
}
3434
},
3535
onSubmit: async (input, state) => {
36+
// await editor(JSON.stringify({input, state}, null, 2));
37+
if (state?.focused?.asTyped && state?.focused?.value === 'select-anyway') {
38+
setFlagValue({
39+
name: path.parse(input).base,
40+
value: input
41+
});
42+
return preventSubmit;
43+
}
3644
if (state?.focused?.miss) {
37-
let selectedPath = input
38-
let doesPathExist = await pathExists(selectedPath)
39-
let type = "file"
45+
let selectedPath = input;
46+
let doesPathExist = await pathExists(selectedPath);
47+
let type = "file";
4048
if (!doesPathExist) {
4149
const value = state?.focused
42-
?.value as PathDefaultMissingValues
50+
?.value;
4351
if (value === "create-file") {
44-
await ensureFile(selectedPath)
52+
await ensureFile(selectedPath);
4553
}
4654
if (value === "create-folder") {
47-
type = "folder"
48-
await ensureDir(selectedPath)
49-
}
50-
if (value === "select-anyway") {
51-
type = "file"
52-
submit(selectedPath)
55+
type = "folder";
56+
await ensureDir(selectedPath);
5357
}
5458
}
55-
5659
let pathChoice = {
5760
img: kitPath("icons", `${type}.svg`),
5861
name: path.parse(selectedPath).base,
5962
value: selectedPath,
60-
}
61-
62-
setChoices([pathChoice])
63-
setFlagValue(pathChoice)
64-
65-
return preventSubmit
63+
};
64+
setChoices([pathChoice]);
65+
setFlagValue(pathChoice);
66+
return preventSubmit;
6667
}
6768
if (!state?.flag) {
68-
await setFlagValue(state?.focused)
69-
return preventSubmit
69+
await setFlagValue(state?.focused);
70+
return preventSubmit;
7071
}
7172
},
7273
})

src/target/path/path.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ let __pathSelector = async (config: string | PathConfig = home(), actions?: Acti
230230
name: '{input}',
231231
description: 'Select full path as typed',
232232
asTyped: true,
233-
value: path.join(startPath, currentInput)
233+
value: 'select-anyway'
234234
});
235235

236236
await setChoices(choices, {

0 commit comments

Comments
 (0)