From 39af624faa6909ea16f1815e819915c6b95d3bd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Mon, 19 Jul 2021 20:21:27 +0800 Subject: path in config supports `~/xxxx` --- script/workspace/workspace.lua | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'script/workspace/workspace.lua') diff --git a/script/workspace/workspace.lua b/script/workspace/workspace.lua index b98face5..73b6138d 100644 --- a/script/workspace/workspace.lua +++ b/script/workspace/workspace.lua @@ -13,6 +13,7 @@ local progress = require 'progress' local define = require "proto.define" local client = require 'client' local plugin = require 'plugin' +local util = require 'utility' local m = {} m.type = 'workspace' @@ -460,6 +461,7 @@ function m.normalize(path) return (ROOT / 'meta' / '3rd'):string() end end) + path = util.expandPath(path) if platform.OS == 'Windows' then path = path:gsub('[/\\]+', '\\') :gsub('[/\\]+$', '') @@ -485,10 +487,15 @@ function m.getAbsolutePath(path) return path end ----@param uri uri +---@param uriOrPath uri|string ---@return string -function m.getRelativePath(uri) - local path = furi.decode(uri) +function m.getRelativePath(uriOrPath) + local path + if uriOrPath:sub(1, 5) == 'file:' then + path = furi.decode(uriOrPath) + else + path = uriOrPath + end if not m.path then local relative = m.normalize(path) return relative:gsub('^[/\\]+', '') -- cgit v1.2.3