Skip to content

Commit 176be59

Browse files
committed
feat: enhance action flags with new rename and move-and-rename functionalities
- Added 'Rename' action to allow users to rename selected files with a shortcut. - Introduced 'Move and Rename' action for moving files while renaming them, enhancing file management capabilities. - Updated existing action flags for better readability and consistency in code structure.
1 parent 35921f4 commit 176be59

File tree

2 files changed

+49
-24
lines changed

2 files changed

+49
-24
lines changed

src/main/common.ts

Lines changed: 45 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -56,18 +56,18 @@ export let actionFlags: ActionFlag[] = [
5656
},
5757
...(isMac
5858
? [
59-
{
60-
name: 'Show Info',
61-
value: 'info',
62-
shortcut: `${cmd}+i`,
63-
action: async (selectedFile) => {
64-
await applescript(`
59+
{
60+
name: 'Show Info',
61+
value: 'info',
62+
shortcut: `${cmd}+i`,
63+
action: async (selectedFile) => {
64+
await applescript(`
6565
set aFile to (POSIX file "${selectedFile}") as alias
6666
tell application "Finder" to open information window of aFile
6767
`)
68-
}
6968
}
70-
]
69+
}
70+
]
7171
: []),
7272
{
7373
name: 'Open Path in Kit Term',
@@ -133,20 +133,20 @@ export let actionFlags: ActionFlag[] = [
133133
},
134134
...(process.env?.KIT_OPEN_IN
135135
? [
136-
{
137-
name: `Open with ${process.env.KIT_OPEN_IN}`,
138-
value: 'open_in_custom',
139-
action: async (selectedFile) => {
140-
hide()
141-
if (isMac) {
142-
let command = `${process.env.KIT_OPEN_IN} '${selectedFile}'`
143-
await exec(command)
144-
} else {
145-
await exec(`"${process.env.KIT_OPEN_IN}" '${selectedFile}'`)
146-
}
136+
{
137+
name: `Open with ${process.env.KIT_OPEN_IN}`,
138+
value: 'open_in_custom',
139+
action: async (selectedFile) => {
140+
hide()
141+
if (isMac) {
142+
let command = `${process.env.KIT_OPEN_IN} '${selectedFile}'`
143+
await exec(command)
144+
} else {
145+
await exec(`"${process.env.KIT_OPEN_IN}" '${selectedFile}'`)
147146
}
148147
}
149-
]
148+
}
149+
]
150150
: []),
151151
{
152152
name: 'Copy to...',
@@ -188,6 +188,17 @@ export let actionFlags: ActionFlag[] = [
188188
await copyFile(selectedFile, path.resolve(destination))
189189
}
190190
},
191+
{
192+
name: 'Rename',
193+
value: 'rename',
194+
shortcut: `${cmd}+r`,
195+
action: async (selectedFile) => {
196+
let newName = await arg({
197+
hint: `Rename ${path.basename(selectedFile)} to:`
198+
})
199+
mv(selectedFile, path.resolve(path.dirname(selectedFile), newName))
200+
}
201+
},
191202
{
192203
name: 'Move',
193204
value: 'move',
@@ -201,6 +212,20 @@ export let actionFlags: ActionFlag[] = [
201212
mv(selectedFile, destFolder)
202213
}
203214
},
215+
// TODO: Need to hide "foo is not a path" when in this mode
216+
{
217+
name: "Move and Rename",
218+
value: "move-and-rename",
219+
shortcut: `${cmd}+shift+m`,
220+
action: async (selectedFile) => {
221+
let newPath = await path({
222+
startPath: path.dirname(selectedFile),
223+
hint: `Rename ${path.basename(selectedFile)} path:`
224+
})
225+
226+
mv(selectedFile, newPath)
227+
}
228+
},
204229
{
205230
name: 'Copy Path',
206231
value: 'copy',

src/workers/cache-grouped-scripts-worker.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,21 +178,21 @@ const cacheMainScripts = async (id: string, stamp: Stamp | null) => {
178178
if (!stampFilePath || stampFilePath === cachedStampFilePath) {
179179
if (cachedMessage) {
180180
// Reuse cached result
181-
logToParent(`${id}: Reusing cached result for ${stampFilePath}`)
181+
logToParent(`[SCRIPTS RENDER] Worker ${id}: Reusing cached result for ${stampFilePath} with ${cachedMessage.scripts.length} scripts`)
182182
parentPort?.postMessage({ ...cachedMessage, id })
183183
return
184184
}
185185
}
186186

187187
// Otherwise, compute fresh results
188-
logToParent(`${id}: Parsing main menu`)
188+
logToParent(`[SCRIPTS RENDER] Worker ${id}: Starting parseMainMenu for ${stampFilePath}`)
189189
const message = await parseMainMenu(stamp)
190190

191191
// Cache results for next time
192-
cachedMessage
192+
cachedMessage = message
193193
cachedStampFilePath = stampFilePath
194194

195-
logToParent(`${id}: Sending fresh result for ${stampFilePath}`)
195+
logToParent(`[SCRIPTS RENDER] Worker ${id}: Sending fresh result for ${stampFilePath} with ${message.scripts.length} scripts`)
196196
parentPort?.postMessage({ ...message, id })
197197
} catch (error) {
198198
logToParent(`Error caching main scripts: ${error}`)

0 commit comments

Comments
 (0)