From 7af7b9ee9d1075007aedd600126fb56462277b21 Mon Sep 17 00:00:00 2001 From: JrmLg <63566435+JrmLg@users.noreply.github.com> Date: Thu, 7 Sep 2023 14:58:38 +0200 Subject: [PATCH 1/4] Improved message readability when renaming a file. --- src/source/sources/file/fileActions.ts | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/source/sources/file/fileActions.ts b/src/source/sources/file/fileActions.ts index 070ef6b..f6d355b 100644 --- a/src/source/sources/file/fileActions.ts +++ b/src/source/sources/file/fileActions.ts @@ -645,17 +645,25 @@ export function loadFileActions(action: ActionSource) { let targetPath: string | undefined; + let cwd = await nvim.call('getcwd') + let path = node.fullpath.replace(cwd, '') + let renameInCwd = path !== node.fullpath + + let targetPath; targetPath = await input( - `Rename: ${node.fullpath} ->`, - node.fullpath, - 'file', + `Rename: `, + path, + "file" ); - - targetPath = targetPath?.trim(); + + targetPath = targetPath == null ? void 0 : targetPath.trim(); if (!targetPath) { - return; + return; + } + + if (renameInCwd) { + targetPath = cwd + targetPath } - await overwritePrompt( 'rename', [ From 7bd80987ba9b123ff651d18f6c980e4066ce75f4 Mon Sep 17 00:00:00 2001 From: JrmLg <63566435+JrmLg@users.noreply.github.com> Date: Fri, 8 Sep 2023 11:06:42 +0200 Subject: [PATCH 2/4] Removing duplicate variable - Improved message readability when renaming a file --- src/source/sources/file/fileActions.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/source/sources/file/fileActions.ts b/src/source/sources/file/fileActions.ts index f6d355b..931fef8 100644 --- a/src/source/sources/file/fileActions.ts +++ b/src/source/sources/file/fileActions.ts @@ -649,13 +649,13 @@ export function loadFileActions(action: ActionSource) { let path = node.fullpath.replace(cwd, '') let renameInCwd = path !== node.fullpath - let targetPath; targetPath = await input( `Rename: `, path, "file" ); + targetPath = targetPath?.trim(); targetPath = targetPath == null ? void 0 : targetPath.trim(); if (!targetPath) { return; From 1507dad111d0d33bd85b0f28c51ee30b10215450 Mon Sep 17 00:00:00 2001 From: JrmLg <63566435+JrmLg@users.noreply.github.com> Date: Fri, 8 Sep 2023 12:37:32 +0200 Subject: [PATCH 3/4] Syntax fix - Improved message readability when renaming a file.ts --- src/source/sources/file/fileActions.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/source/sources/file/fileActions.ts b/src/source/sources/file/fileActions.ts index 931fef8..0f2e2fe 100644 --- a/src/source/sources/file/fileActions.ts +++ b/src/source/sources/file/fileActions.ts @@ -645,22 +645,22 @@ export function loadFileActions(action: ActionSource) { let targetPath: string | undefined; - let cwd = await nvim.call('getcwd') - let path = node.fullpath.replace(cwd, '') - let renameInCwd = path !== node.fullpath + const cwd = await nvim.call('getcwd'); + const path = node.fullpath.replace(cwd, ''); + const renameInCwd = path !== node.fullpath; targetPath = await input( - `Rename: `, - path, - "file" + `Rename: `, + path, + "file" ); targetPath = targetPath?.trim(); targetPath = targetPath == null ? void 0 : targetPath.trim(); if (!targetPath) { - return; + return; } - + if (renameInCwd) { targetPath = cwd + targetPath } From d0a7d9fa218401e9462afe6d8cdaf94158af5a70 Mon Sep 17 00:00:00 2001 From: JrmLg <63566435+JrmLg@users.noreply.github.com> Date: Sat, 9 Sep 2023 13:06:01 +0200 Subject: [PATCH 4/4] Fixed syntax with project settings. --- src/source/sources/file/fileActions.ts | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/source/sources/file/fileActions.ts b/src/source/sources/file/fileActions.ts index 0f2e2fe..0edda34 100644 --- a/src/source/sources/file/fileActions.ts +++ b/src/source/sources/file/fileActions.ts @@ -306,8 +306,8 @@ export function loadFileActions(action: ActionSource) { await file.copyToClipboard( nodes ? nodes - .map((it) => pathLib.relative(file.root, it.fullpath)) - .join('\n') + .map((it) => pathLib.relative(file.root, it.fullpath)) + .join('\n') : file.root, ); await window.showInformationMessage( @@ -645,16 +645,12 @@ export function loadFileActions(action: ActionSource) { let targetPath: string | undefined; - const cwd = await nvim.call('getcwd'); - const path = node.fullpath.replace(cwd, ''); - const renameInCwd = path !== node.fullpath; + const cwd: string = await nvim.call('getcwd'); + const path: string = node.fullpath.replace(cwd, ''); + const renameInCwd: boolean = path !== node.fullpath; + + targetPath = await input(`Rename: `, path, 'file'); - targetPath = await input( - `Rename: `, - path, - "file" - ); - targetPath = targetPath?.trim(); targetPath = targetPath == null ? void 0 : targetPath.trim(); if (!targetPath) { @@ -662,8 +658,9 @@ export function loadFileActions(action: ActionSource) { } if (renameInCwd) { - targetPath = cwd + targetPath + targetPath = cwd + targetPath; } + await overwritePrompt( 'rename', [