修复对json文件的支持
parent
a025463129
commit
36696c4567
|
@ -1,5 +1,8 @@
|
|||
# 更新日志(Changed Logs)
|
||||
|
||||
### v1.0.1
|
||||
- 修复对json文件的支持
|
||||
|
||||
### v1.0.0
|
||||
- 支持微信小程序, vue项目的引入
|
||||
- 以项目目录为根目录
|
|
@ -4,7 +4,7 @@
|
|||
[![Version](https://vsmarketplacebadge.apphb.com/version-short/yutent.auto-path.svg)](https://marketplace.visualstudio.com/items?itemName=yutent.auto-path)
|
||||
[![Rating](https://vsmarketplacebadge.apphb.com/rating-short/yutent.auto-path.svg)](https://marketplace.visualstudio.com/items?itemName=yutent.auto-path)
|
||||
[![Installs](https://vsmarketplacebadge.apphb.com/installs/yutent.auto-path.svg)](https://marketplace.visualstudio.com/items?itemName=yutent.auto-path)
|
||||
[![Build Status](https://travis-ci.org/yutent/auto-path.svg?branch=master)](https://travis-ci.org/yutent/auto-path)
|
||||
|
||||
|
||||
|
||||
## 概念说明
|
||||
|
|
17
index.js
17
index.js
|
@ -8,7 +8,7 @@ const vsc = require('vscode')
|
|||
const { resolve, dirname, join } = require('path')
|
||||
const fs = require('fs')
|
||||
|
||||
const FILE = vsc.CompletionItemKind.File
|
||||
const FILE = vsc.CompletionItemKind.Text
|
||||
const FOLDER = vsc.CompletionItemKind.Folder
|
||||
|
||||
/**
|
||||
|
@ -48,6 +48,12 @@ function getPrefixTxt(line, idx) {
|
|||
return txt.slice(n + 1)
|
||||
}
|
||||
|
||||
function item(text, type, p) {
|
||||
var _ = new vsc.CompletionItem(text, type)
|
||||
_.range = new vsc.Range(p, p)
|
||||
return _
|
||||
}
|
||||
|
||||
let options = {
|
||||
isMiniApp: false, // 是否小程序
|
||||
extendWorkspace: null // 额外的项目目录, 一般是 vue项目中的 src目录
|
||||
|
@ -100,9 +106,10 @@ class AutoPath {
|
|||
list = list.map(k => {
|
||||
let t = options.isMiniApp ? FILE : isdir(k) ? FOLDER : FILE
|
||||
k = k.slice(currDirFixed.length)
|
||||
return new vsc.CompletionItem(k, t)
|
||||
return item(k, t, pos)
|
||||
})
|
||||
list.unshift(new vsc.CompletionItem('', FILE))
|
||||
list.unshift(item('', FILE, pos))
|
||||
|
||||
return Promise.resolve(list)
|
||||
}
|
||||
}
|
||||
|
@ -112,8 +119,12 @@ 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'))) {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"name": "auto-path",
|
||||
"displayName": "auto-path",
|
||||
"description": "🔥 自动提示文件路径, 方便引入项目为的文件",
|
||||
"version": "1.0.0",
|
||||
"version": "1.0.1",
|
||||
"publisher": "yutent",
|
||||
"author": "Yutent [@yutent]",
|
||||
"icon": "logo.png",
|
||||
|
|
Loading…
Reference in New Issue