Skip to content

Commit 2ce2863

Browse files
committed
chore: update workspace file exclusions and refactor exports
1 parent 606f42f commit 2ce2863

4 files changed

Lines changed: 18 additions & 17 deletions

File tree

.vscode/settings.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@
22
{
33
"files.exclude": {
44
"out": false, // set this to true to hide the "out" folder with the compiled JS files
5-
"dist": false // set this to true to hide the "dist" folder with the compiled JS files
5+
"dist": true, // set this to true to hide the "dist" folder with the compiled JS files
6+
"node_modules":true,
7+
"es*js":true,
8+
"LICENSE":true,
9+
".vscode-test*":true,
10+
"package-lock.json":true,
11+
"tsconfig.json":true
612
},
713
"search.exclude": {
814
"out": true, // set this to false to include "out" folder in search results

src/constants.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
1-
export { EXTENSION_ID, packageJSON, IS_DEBUG, setIS_DEBUG };
2-
31
import * as vscode from "vscode";
42

5-
let IS_DEBUG: boolean;
3+
export let IS_DEBUG: boolean;
4+
5+
export const setIS_DEBUG = (b: boolean) => { IS_DEBUG = b; };
66

7-
const setIS_DEBUG = (b: boolean) => { IS_DEBUG = b; };
7+
export const EXTENSION_ID = "2bitbit.trash4wsl-in-vscode";
88

9-
const EXTENSION_ID = "2bitbit.trash4wsl-in-vscode";
9+
export const packageJSON: any = vscode.extensions.getExtension(EXTENSION_ID)?.packageJSON;
1010

11-
const packageJSON: any =
12-
vscode.extensions.getExtension(EXTENSION_ID)?.packageJSON;
13-
1411
/*trash-restore输出格式(.表示空格): ...0 2025-05-31 17:28:28 /home/finnwsl/test-wsl/dir
1512
...1 2025-05-31 17:36:04 /home/finnwsl/test-wsl/sample.txt
1613
What file to restore [0..1]:.

src/fsUtils.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
// 负责各种的文件相关信息;
22
// 所有输出路径都必须视情况在对应情境中考虑 **转义**。
33

4-
export { Uris2Paths, getWorkspacePaths, isFile, normalizePaths };
54

65
import * as vscode from "vscode";
76

87
/** 获取当前工作区路径:以数组形式返回。 */
9-
function getWorkspacePaths(): string[] {
8+
export function getWorkspacePaths(): string[] {
109
const workspacePaths: string[] = [];
1110
if (vscode.workspace.workspaceFolders) {
1211
for (const workspaceFolder of vscode.workspace.workspaceFolders) {
@@ -21,7 +20,7 @@ function getWorkspacePaths(): string[] {
2120
* @param uris 所有要处理的文件/文件夹的 URI 数组
2221
* @returns 要处理的文件/文件夹的路径,转义后的数组
2322
*/
24-
function Uris2Paths(uris: vscode.Uri[]): string[] {
23+
export function Uris2Paths(uris: vscode.Uri[]): string[] {
2524
return uris // 让父目录永远排在子目录/文件前面。这样删除的时候,父目录会先被删除,子目录/文件后被删除。便于恢复。
2625
.map((f) => f.fsPath)
2726
.sort((a, b) => {
@@ -37,14 +36,14 @@ function Uris2Paths(uris: vscode.Uri[]): string[] {
3736
}
3837

3938
/** 判断给定的path是文件还是目录*/
40-
function isFile(path: string): boolean {
39+
export function isFile(path: string): boolean {
4140
// 不能使用 fsUtils.isFile(path) 因为这些文件已经被删除到回收站了
4241
const hasExtension = /\.[^/\.]+$/.test(path);
4342
const endsWithSlash = path.endsWith("/") || path.endsWith("\\");
4443
return hasExtension && !endsWithSlash;
4544
}
4645

4746
/**去掉首尾空格与换行符以及移除空字符串 */
48-
function normalizePaths(paths: string[]): string[] {
47+
export function normalizePaths(paths: string[]): string[] {
4948
return paths.map((path) => path.trim()).filter((path) => path !== "");
5049
}

src/trashPutCommand.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
import * as vscode from "vscode";
22
import { normalizePaths, Uris2Paths } from "./fsUtils.js";
33
import { TrashService } from "./TrashService.js";
4-
export { trashPutViaContextMenu, trashPutViaShortcut };
54

65
/** 在explorer的右键上下文菜单点击,执行trash-put */
7-
async function trashPutViaContextMenu(_: vscode.Uri, uris: vscode.Uri[]) {
6+
export async function trashPutViaContextMenu(_: vscode.Uri, uris: vscode.Uri[]) {
87
// 处理参数:uris已经包含了所有的文件/文件夹,第一个参数是右键单击的那个文件/文件夹uri,不必理会。
98
let paths = Uris2Paths(uris);
109
paths = normalizePaths(paths);
1110
await execTrashPut(paths);
1211
}
1312

1413
/**在explorer选中,通过快捷键执行trash-put */
15-
async function trashPutViaShortcut() {
14+
export async function trashPutViaShortcut() {
1615
const originalClipboard = await vscode.env.clipboard.readText();
1716
vscode.commands.executeCommand("copyFilePath");
1817
const selectedPaths = await vscode.env.clipboard.readText();

0 commit comments

Comments
 (0)