Add tab renaming

pull/7109/head
Nikodem Rabuliński 1 year ago
parent 66f009b873
commit 77bd9450a4
No known key found for this signature in database

@ -1659,6 +1659,24 @@ fn tab_new(
Ok(()) Ok(())
} }
fn tab_rename(
cx: &mut compositor::Context,
args: &[Cow<str>],
event: PromptEvent,
) -> anyhow::Result<()> {
if event != PromptEvent::Validate {
return Ok(());
}
if args.len() != 1 {
anyhow::bail!("Bad arguments. Usage: `:tab-rename name`");
}
cx.editor.tabs.curr_tab_mut().name = args[0].to_string();
Ok(())
}
fn vsplit( fn vsplit(
cx: &mut compositor::Context, cx: &mut compositor::Context,
args: &[Cow<str>], args: &[Cow<str>],
@ -2975,6 +2993,13 @@ pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[
fun: tab_previous, fun: tab_previous,
signature: CommandSignature::none(), signature: CommandSignature::none(),
}, },
TypableCommand {
name: "tab-rename",
aliases: &[],
doc: "Change the name of the current tab.",
fun: tab_rename,
signature: CommandSignature::none(),
},
TypableCommand { TypableCommand {
name: "vsplit", name: "vsplit",
aliases: &["vs"], aliases: &["vs"],

@ -46,6 +46,11 @@ impl Tabs {
self.tabs.iter() self.tabs.iter()
} }
#[inline]
pub fn curr_tab_mut(&mut self) -> &mut Tab {
self.tabs.get_mut(self.focus).unwrap()
}
#[inline] #[inline]
pub fn new_tab(&mut self) -> TabId { pub fn new_tab(&mut self) -> TabId {
let area = self.curr_tree().area(); let area = self.curr_tree().area();

Loading…
Cancel
Save