diff --git a/CHANGELOG.md b/CHANGELOG.md index 68f1efe..61232e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # 更新日志(Changed Logs) +### v1.0.1 +- 修复对json文件的支持 + ### v1.0.0 - 支持微信小程序, vue项目的引入 - 以项目目录为根目录 \ No newline at end of file diff --git a/README.md b/README.md index a0e4845..95e07a9 100644 --- a/README.md +++ b/README.md @@ -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) + ## 概念说明 diff --git a/index.js b/index.js index 0fd658e..ed7863a 100644 --- a/index.js +++ b/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'))) { diff --git a/package.json b/package.json index 6245355..b0d1dfa 100644 --- a/package.json +++ b/package.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",