删除调试代码;修复对../的支持;过滤掉当前文件本身

master 1.0.2
yutent 2022-02-18 10:16:48 +08:00
parent 36696c4567
commit fda19e7353
3 changed files with 20 additions and 21 deletions

View File

@ -23,7 +23,7 @@
- 当输入 `/`开头时, 只读取`pages`或`subPackages`中的路径。
2. vue项目
> 判断根目录是否有 `vue.config.js`或`vite.config.js`, 有则认为是vue项目。
> 判断根目录`package.json`且有使用依赖`vue`, 有则认为是vue项目。
- 当输入 `./` 开头时, 读取当前目录下的文件。
- 当输入 `@/`开头时, 只读取`src/`中的路径。
- 当输入 `/`开头时, 读取根目录的文件。

View File

@ -8,7 +8,7 @@ const vsc = require('vscode')
const { resolve, dirname, join } = require('path')
const fs = require('fs')
const FILE = vsc.CompletionItemKind.Text
const FILE = vsc.CompletionItemKind.File
const FOLDER = vsc.CompletionItemKind.Folder
/**
@ -73,7 +73,7 @@ class AutoPath {
return
}
if (inputTxt.startsWith('./')) {
if (inputTxt.startsWith('./') || inputTxt.startsWith('../')) {
list.push(...ls(currDirFixed))
} else {
// 小程序
@ -103,11 +103,14 @@ class AutoPath {
}
}
list = list.map(k => {
let t = options.isMiniApp ? FILE : isdir(k) ? FOLDER : FILE
k = k.slice(currDirFixed.length)
return item(k, t, pos)
})
list = list
.filter(it => it !== doc.fileName)
.map(k => {
let t = options.isMiniApp ? FILE : isdir(k) ? FOLDER : FILE
k = k.slice(currDirFixed.length)
return item(k, t, pos)
})
list.unshift(item('', FILE, pos))
return Promise.resolve(list)
@ -119,12 +122,8 @@ function __init__() {
if (folders && folders.length) {
options.workspace = folders[0].uri.path
} else {
options.workspace = '/opt/www/web/small-world'
}
console.log()
if (options.workspace) {
// 判断是否是小程序
if (isfile(join(options.workspace, 'app.json'))) {
@ -135,13 +134,13 @@ function __init__() {
}
}
// 简单判断是否是vue项目
if (
isfile(join(options.workspace, 'vue.config.js')) ||
isfile(join(options.workspace, 'vite.config.js'))
) {
let extendWorkspace = join(options.workspace, 'src/')
if (isdir(extendWorkspace)) {
options.extendWorkspace = extendWorkspace
if (isfile(join(options.workspace, 'package.json'))) {
let conf = require(join(options.workspace, 'package.json'))
if (conf.dependencies.vue) {
let extendWorkspace = join(options.workspace, 'src/')
if (isdir(extendWorkspace)) {
options.extendWorkspace = extendWorkspace
}
}
}
}

View File

@ -2,7 +2,7 @@
"name": "auto-path",
"displayName": "auto-path",
"description": "🔥 自动提示文件路径, 方便引入项目为的文件",
"version": "1.0.1",
"version": "1.0.2",
"publisher": "yutent",
"author": "Yutent [@yutent]",
"icon": "logo.png",
@ -28,7 +28,7 @@
],
"scripts": {
"start": "esbuild index.js --bundle --outfile=out.js --external:vscode --format=cjs --platform=node",
"vscode:prepublish": "npm start -- --minify"
"build": "npm start -- --minify"
},
"license": "MIT",
"devDependencies": {