Merge pull request #3017 from Rummskartoffel/patch-1

Fix #3016
This commit is contained in:
Oliver Blanthorn 2020-11-23 20:48:51 +00:00 committed by GitHub
commit e30385eba4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 9 deletions

View file

@ -4745,7 +4745,7 @@ async function js_helper(str: string[]) {
let sourcePath = jsContent let sourcePath = jsContent
if (fromRC) { if (fromRC) {
const sep = "/" const sep = "/"
const rcPath = (await Native.getrcpath()).split(sep).slice(0, -1) const rcPath = (await Native.getrcpath("unix")).split(sep).slice(0, -1)
sourcePath = [...rcPath, sourcePath].join(sep) sourcePath = [...rcPath, sourcePath].join(sep)
} }
const file = await Native.read(sourcePath) const file = await Native.read(sourcePath)

View file

@ -58,12 +58,16 @@ async function sendNativeMsg(
} }
} }
export async function getrcpath(): Promise<string> { export async function getrcpath(separator: "unix" | "auto" = "auto"): Promise<string> {
const res = await sendNativeMsg("getconfigpath", {}) const res = await sendNativeMsg("getconfigpath", {})
if (res.code !== 0) throw new Error("getrcpath error: " + res.code) if (res.code !== 0) throw new Error("getrcpath error: " + res.code)
return res.content if (separator == "unix" && (await browserBg.runtime.getPlatformInfo()).os == "win") {
return res.content.replace(/\\/g, "/")
}
else
return res.content
} }
export async function getrc(): Promise<string> { export async function getrc(): Promise<string> {
@ -103,7 +107,7 @@ export async function getBestEditor(): Promise<string> {
if (os === "mac") { if (os === "mac") {
gui_candidates = [ gui_candidates = [
"/Applications/MacVim.app/Contents/bin/mvim -f" + "/Applications/MacVim.app/Contents/bin/mvim -f" +
vim_positioning_arg, vim_positioning_arg,
"/usr/local/bin/vimr --wait --nvim +only", "/usr/local/bin/vimr --wait --nvim +only",
] ]
// if anyone knows of any "sensible" terminals that let you send them commands to run, // if anyone knows of any "sensible" terminals that let you send them commands to run,
@ -211,8 +215,8 @@ export async function nativegate(
if (interactive) if (interactive)
logger.error( logger.error(
"# Please update to native messenger " + "# Please update to native messenger " +
version + version +
", for example by running `:updatenative`.", ", for example by running `:updatenative`.",
) )
// TODO: add update procedure and document here. // TODO: add update procedure and document here.
return false return false
@ -423,7 +427,7 @@ export async function ff_cmdline(): Promise<string[]> {
} else { } else {
const output = await pyeval( const output = await pyeval(
'handleMessage({"cmd": "run", ' + 'handleMessage({"cmd": "run", ' +
'"command": "ps -p " + str(os.getppid()) + " -oargs="})["content"]', '"command": "ps -p " + str(os.getppid()) + " -oargs="})["content"]',
) )
return output.content.trim().split(" ") return output.content.trim().split(" ")
} }
@ -497,7 +501,7 @@ export async function getProfileUncached() {
try { try {
iniObject = await parseProfilesIni(iniContent.content, ffDir) iniObject = await parseProfilesIni(iniContent.content, ffDir)
iniSucceeded = true iniSucceeded = true
} catch (e) {} } catch (e) { }
} }
const curProfileDir = config.get("profiledir") const curProfileDir = config.get("profiledir")
@ -730,7 +734,7 @@ export async function getConfElsePref(
if (option === undefined) { if (option === undefined) {
try { try {
option = await getPref(prefName) option = await getPref(prefName)
} catch (e) {} } catch (e) { }
} }
return option return option
} }