修复对json文件的支持

master
yutent 2022-02-17 14:53:09 +08:00
parent a025463129
commit 36696c4567
4 changed files with 19 additions and 5 deletions

View File

@ -1,5 +1,8 @@
# 更新日志(Changed Logs) # 更新日志(Changed Logs)
### v1.0.1
- 修复对json文件的支持
### v1.0.0 ### v1.0.0
- 支持微信小程序, vue项目的引入 - 支持微信小程序, vue项目的引入
- 以项目目录为根目录 - 以项目目录为根目录

View File

@ -4,7 +4,7 @@
[![Version](https://vsmarketplacebadge.apphb.com/version-short/yutent.auto-path.svg)](https://marketplace.visualstudio.com/items?itemName=yutent.auto-path) [![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) [![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) [![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)
## 概念说明 ## 概念说明

View File

@ -8,7 +8,7 @@ const vsc = require('vscode')
const { resolve, dirname, join } = require('path') const { resolve, dirname, join } = require('path')
const fs = require('fs') const fs = require('fs')
const FILE = vsc.CompletionItemKind.File const FILE = vsc.CompletionItemKind.Text
const FOLDER = vsc.CompletionItemKind.Folder const FOLDER = vsc.CompletionItemKind.Folder
/** /**
@ -48,6 +48,12 @@ function getPrefixTxt(line, idx) {
return txt.slice(n + 1) 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 = { let options = {
isMiniApp: false, // 是否小程序 isMiniApp: false, // 是否小程序
extendWorkspace: null // 额外的项目目录, 一般是 vue项目中的 src目录 extendWorkspace: null // 额外的项目目录, 一般是 vue项目中的 src目录
@ -100,9 +106,10 @@ class AutoPath {
list = list.map(k => { list = list.map(k => {
let t = options.isMiniApp ? FILE : isdir(k) ? FOLDER : FILE let t = options.isMiniApp ? FILE : isdir(k) ? FOLDER : FILE
k = k.slice(currDirFixed.length) 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) return Promise.resolve(list)
} }
} }
@ -112,8 +119,12 @@ function __init__() {
if (folders && folders.length) { if (folders && folders.length) {
options.workspace = folders[0].uri.path options.workspace = folders[0].uri.path
} else {
options.workspace = '/opt/www/web/small-world'
} }
console.log()
if (options.workspace) { if (options.workspace) {
// 判断是否是小程序 // 判断是否是小程序
if (isfile(join(options.workspace, 'app.json'))) { if (isfile(join(options.workspace, 'app.json'))) {

View File

@ -2,7 +2,7 @@
"name": "auto-path", "name": "auto-path",
"displayName": "auto-path", "displayName": "auto-path",
"description": "🔥 自动提示文件路径, 方便引入项目为的文件", "description": "🔥 自动提示文件路径, 方便引入项目为的文件",
"version": "1.0.0", "version": "1.0.1",
"publisher": "yutent", "publisher": "yutent",
"author": "Yutent [@yutent]", "author": "Yutent [@yutent]",
"icon": "logo.png", "icon": "logo.png",