mirror of
https://github.com/vale981/tridactyl
synced 2025-03-06 01:51:40 -05:00
Revert "Add FileSystem completion"
This partially reverts commit698fc6a
and25af877
. The completion was causing breaking tabopen and other completions for people with outdated native messengers.
This commit is contained in:
parent
25af877622
commit
830065c4c6
4 changed files with 3 additions and 87 deletions
|
@ -2,7 +2,6 @@
|
|||
* Background functions for the native messenger interface
|
||||
*/
|
||||
|
||||
import * as Messaging from "@src/lib/messaging"
|
||||
import * as semverCompare from "semver-compare"
|
||||
import * as config from "@src/lib/config"
|
||||
import { browserBg } from "@src/lib/webext"
|
||||
|
@ -17,7 +16,6 @@ type MessageCommand =
|
|||
| "read"
|
||||
| "write"
|
||||
| "temp"
|
||||
| "list_dir"
|
||||
| "mkdir"
|
||||
| "move"
|
||||
| "eval"
|
||||
|
@ -56,10 +54,11 @@ async function sendNativeMsg(
|
|||
}
|
||||
}
|
||||
|
||||
export async function getrcpath(): Promise<string> {
|
||||
export async function getrcpath(): Promise <string> {
|
||||
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
|
||||
}
|
||||
|
@ -261,10 +260,6 @@ export async function move(from: string, to: string) {
|
|||
return sendNativeMsg("move", { from, to })
|
||||
}
|
||||
|
||||
export async function listDir(dir: string) {
|
||||
return sendNativeMsg("list_dir", { path: dir })
|
||||
}
|
||||
|
||||
export async function winFirefoxRestart(
|
||||
profiledir: string,
|
||||
browsercmd: string,
|
||||
|
@ -587,6 +582,3 @@ export async function writePref(name: string, value: any) {
|
|||
write(file, text.replace(substr, `pref("${name}", ${value})`))
|
||||
}
|
||||
}
|
||||
|
||||
import * as SELF from "@src/background/native_background"
|
||||
Messaging.addListener("native_background", Messaging.attributeCaller(SELF))
|
||||
|
|
|
@ -8,7 +8,6 @@ import { BufferAllCompletionSource } from "@src/completions/BufferAll"
|
|||
import { BufferCompletionSource } from "@src/completions/Buffer"
|
||||
import { BmarkCompletionSource } from "@src/completions/Bmark"
|
||||
import { ExcmdCompletionSource } from "@src/completions/Excmd"
|
||||
import { FileSystemCompletionSource } from "@src/completions/FileSystem"
|
||||
import { HelpCompletionSource } from "@src/completions/Help"
|
||||
import { HistoryCompletionSource } from "@src/completions/History"
|
||||
import { SettingsCompletionSource } from "@src/completions/Settings"
|
||||
|
@ -67,7 +66,6 @@ function enableCompletions() {
|
|||
new BufferAllCompletionSource(completionsDiv),
|
||||
new BufferCompletionSource(completionsDiv),
|
||||
new ExcmdCompletionSource(completionsDiv),
|
||||
new FileSystemCompletionSource(completionsDiv),
|
||||
new HelpCompletionSource(completionsDiv),
|
||||
new HistoryCompletionSource(completionsDiv),
|
||||
new SettingsCompletionSource(completionsDiv),
|
||||
|
|
|
@ -1,73 +0,0 @@
|
|||
import * as Completions from "@src/completions"
|
||||
import * as Messaging from "@src/lib/messaging"
|
||||
import * as config from "@src/lib/config"
|
||||
|
||||
class FileSystemCompletionOption extends Completions.CompletionOptionHTML
|
||||
implements Completions.CompletionOptionFuse {
|
||||
public fuseKeys = []
|
||||
|
||||
constructor(public value: string) {
|
||||
super()
|
||||
this.fuseKeys = [value]
|
||||
this.html = html`<tr class="FileSystemCompletionOption option">
|
||||
<td class="value">${value}</td>
|
||||
</tr>`
|
||||
}
|
||||
}
|
||||
|
||||
export class FileSystemCompletionSource extends Completions.CompletionSourceFuse {
|
||||
public options: FileSystemCompletionOption[]
|
||||
|
||||
constructor(private _parent) {
|
||||
super(["saveas", "source"], "FileSystemCompletionSource", "FileSystem")
|
||||
|
||||
this._parent.appendChild(this.node)
|
||||
}
|
||||
|
||||
public async onInput(exstr) {
|
||||
this.filter(exstr)
|
||||
}
|
||||
|
||||
public async filter(exstr: string) {
|
||||
if (!exstr || exstr.indexOf(" ") == -1) {
|
||||
this.state = "hidden"
|
||||
return
|
||||
}
|
||||
|
||||
let [cmd, path] = this.splitOnPrefix(exstr)
|
||||
if (!path) path = "."
|
||||
|
||||
if (!["/", "$", "~", "."].find(s => path.startsWith(s))) {
|
||||
// If the path doesn't start with a special character, it is relative to the native messenger, thus use "." as starting point
|
||||
// Does this work on windows?
|
||||
path = "./" + path
|
||||
}
|
||||
|
||||
// Update lastExstr because we modified the path and scoreOptions uses that in order to assign scores
|
||||
this.lastExstr = cmd + path
|
||||
|
||||
let req
|
||||
try {
|
||||
req = await Messaging.message("native_background", "listDir", [
|
||||
path,
|
||||
])
|
||||
} catch (e) {
|
||||
// Failing silently because we can't nativegate (the user is typing stuff in the commandline)
|
||||
this.state = "hidden"
|
||||
return
|
||||
}
|
||||
|
||||
if (req.isDir) {
|
||||
if (!path.endsWith(req.sep)) path += req.sep
|
||||
} else {
|
||||
path = path.substring(0, path.lastIndexOf("/") + 1)
|
||||
}
|
||||
|
||||
this.options = req.files.map(
|
||||
p => new FileSystemCompletionOption(path + p),
|
||||
)
|
||||
|
||||
this.state = "normal"
|
||||
this.updateChain()
|
||||
}
|
||||
}
|
|
@ -11,7 +11,6 @@ export type NonTabMessageType =
|
|||
| "commandline_background"
|
||||
| "controller_background"
|
||||
| "browser_proxy_background"
|
||||
| "native_background"
|
||||
| "download_background"
|
||||
| "performance_background"
|
||||
export type MessageType = TabMessageType | NonTabMessageType
|
||||
|
|
Loading…
Add table
Reference in a new issue