Fix #4605: allow autocmddelete on default autocmds

This commit is contained in:
Oliver Blanthorn 2026-07-22 13:23:25 +02:00
parent b487a712bd
commit 14c7d77cd2
No known key found for this signature in database
GPG key ID: 2BB8C36BB504BFF3
3 changed files with 17 additions and 2 deletions

View file

@ -4941,7 +4941,7 @@ export function autocmddelete(event: string, url: string) {
if (webrequests.requestEvents.includes(event)) {
webrequests.unregisterWebRequestAutocmd(event, url)
}
return config.unset("autocmds", event, url)
return config.set("autocmds", event, url, null)
}
/**

View file

@ -66,6 +66,18 @@ test("keymap unbind default", () => {
expect(exmaps["<Space>"]).toBeUndefined()
})
test("null removes and exports a default autocmd", async () => {
const event = "DocLoad"
const url = "^https://github.com/tridactyl/tridactyl/issues/new$"
expect(get("autocmds", event)[url]).toBe("issue")
await tri.config.set("autocmds", event, url, null)
expect(tri.config.USERCONFIG.autocmds[event][url]).toBeNull()
expect(get("autocmds", event)[url]).toBeUndefined()
expect(tri.config.parseConfig()).toContain(`autocmddelete ${event} ${url}`)
})
test("get in modified inherit keymap", () => {
expect(config["vmaps"]["🕷🕷INHERITS🕷🕷"]).toBe("nmaps")
expect("q" in config["vmaps"]).toBe(true)

View file

@ -2635,8 +2635,11 @@ const parseConfigHelper = (pconf, parseobj, prefix = []) => {
}
} else if (i === "autocmds") {
for (const a of Object.keys(pconf[i][e])) {
const value = pconf[i][e][a]
parseobj.aucmds.push(
`autocmd ${e} ${a} ${pconf[i][e][a]}`,
value === null
? `autocmddelete ${e} ${a}`
: `autocmd ${e} ${a} ${value}`,
)
}
} else if (i === "autocontain") {