Merge pull request #3835 from ivcz/tabrename

Add a :tabrename command
This commit is contained in:
Oliver Blanthorn 2021-07-16 22:39:59 +01:00 committed by GitHub
commit fc98519e80
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 35 additions and 1 deletions

View file

@ -68,7 +68,14 @@ export class BufferCompletionSource extends Completions.CompletionSourceFuse {
constructor(private _parent) {
super(
["tab", "tabclose", "tabdetach", "tabduplicate", "tabmove"],
[
"tab",
"tabclose",
"tabdetach",
"tabduplicate",
"tabmove",
"tabrename",
],
"BufferCompletionSource",
"Tabs",
)
@ -89,6 +96,8 @@ export class BufferCompletionSource extends Completions.CompletionSourceFuse {
async filter(exstr) {
this.lastExstr = exstr
const prefix = this.splitOnPrefix(exstr).shift()
if (prefix === "tabrename ") this.shouldSetStateFromScore = false
return this.onInput(exstr)
}

View file

@ -3524,6 +3524,31 @@ export async function taball(...id: string[]) {
return tab_helper(true, true, ...id)
}
/** Rename current tab.
@hidden
@param name
Tab name.
*/
//#content_helper
export function tabcurrentrename(...name: string[]) {
document.title = name.join(" ")
}
/** Rename a tab.
@param index
Index of the target tab.
@param name
Tab name.
*/
//#background
export async function tabrename(index: string, ...name: string[]) {
const id = await idFromIndex(index)
return Messaging.messageTab(id, "excmd_content", "tabcurrentrename", name)
}
/** Helper to change active tab. Used by [[tab]] and [[taball]].
@param interactive