From 74f20fb7b5563f3349ef3835966885c166acdf21 Mon Sep 17 00:00:00 2001 From: yutent Date: Thu, 17 Mar 2022 14:51:42 +0800 Subject: [PATCH] fixed --- index.js | 13 +++++++++---- package.json | 10 +++++++--- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/index.js b/index.js index 10119e4..197a2d4 100644 --- a/index.js +++ b/index.js @@ -102,7 +102,7 @@ class AutoPath { inputTxt = getPrefixTxt(inputTxt, pos.character) currDirFixed = join(currDir, inputTxt) - // console.log('修正后的inputTxt: ', inputTxt) + // console.log('修正后的inputTxt: ', inputTxt, currDirFixed) if (!inputTxt) { return @@ -130,6 +130,9 @@ class AutoPath { else if (inputTxt.startsWith('@/') && options.extendWorkspace) { currDirFixed = join(options.extendWorkspace, inputTxt.slice(2)) list.push(...ls(currDirFixed)) + } else if (inputTxt.startsWith('~')) { + currDirFixed = inputTxt.replace(/^~/, process.env.HOME) + list.push(...ls(currDirFixed)) } // 其他的 else { @@ -158,6 +161,8 @@ class AutoPath { function __init__() { let folders = vsc.workspace.workspaceFolders + // console.log(folders) + if (folders && folders.length) { options.workspace = folders[0].uri.fsPath } @@ -174,7 +179,7 @@ function __init__() { // 简单判断是否是vue项目 if (isfile(join(options.workspace, 'package.json'))) { let conf = require(join(options.workspace, 'package.json')) - if (conf.dependencies.vue) { + if (conf.dependencies && conf.dependencies.vue) { let extendWorkspace = join(options.workspace, 'src/') if (isdir(extendWorkspace)) { options.extendWorkspace = extendWorkspace @@ -184,7 +189,7 @@ function __init__() { } } -exports.activate = function(ctx) { +exports.activate = function (ctx) { __init__() let ap = new AutoPath() @@ -193,4 +198,4 @@ exports.activate = function(ctx) { ctx.subscriptions.push(auto) } -exports.deactivate = function() {} +exports.deactivate = function () {} diff --git a/package.json b/package.json index 4fe13f7..81b06f1 100644 --- a/package.json +++ b/package.json @@ -2,15 +2,19 @@ "name": "auto-path", "displayName": "auto-path", "description": "🔥 自动提示文件路径, 方便引入项目为的文件", - "version": "1.1.2", + "version": "1.1.3", "publisher": "yutent", "author": "Yutent [@yutent]", "icon": "logo.png", "engines": { "vscode": "^1.49.0" }, - "categories": ["Other"], - "activationEvents": ["*"], + "categories": [ + "Other" + ], + "activationEvents": [ + "*" + ], "main": "out.js", "contributes": {}, "repository": {