Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show infobox to hint textobjects with mi and ma #1686

Next Next commit
Show infobox to hint textobjects with mi and ma
  • Loading branch information
EpocSquadron committed Feb 27, 2022
commit 0b4e6ec74846189b71b4547a3b7c73585de3ade3
27 changes: 26 additions & 1 deletion helix-term/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5353,6 +5353,7 @@ fn select_textobject_inner(cx: &mut Context) {

fn select_textobject(cx: &mut Context, objtype: textobject::TextObject) {
let count = cx.count();

cx.on_next_key(move |cx, event| {
if let Some(ch) = event.char() {
let textobject = move |editor: &mut Editor| {
Expand Down Expand Up @@ -5400,9 +5401,33 @@ fn select_textobject(cx: &mut Context, objtype: textobject::TextObject) {
doc.set_selection(view.id, selection);
};
textobject(cx.editor);
cx.editor.autoinfo = None;
archseer marked this conversation as resolved.
Show resolved Hide resolved
cx.editor.last_motion = Some(Motion(Box::new(textobject)));
}
})
});

if let Some(title) = match objtype {
textobject::TextObject::Inside => Some("Match inside"),
textobject::TextObject::Around => Some("Match around"),
textobject::TextObject::Movement => None,
EpocSquadron marked this conversation as resolved.
Show resolved Hide resolved
} {
let help_text = vec![
("w", "Word"),
("W", "WORD"),
("c", "Class (tree-sitter)"),
("f", "Function (tree-sitter)"),
("p", "Parameter (tree-sitter)"),
("m", "Matching delimiter under cursor"),
];
EpocSquadron marked this conversation as resolved.
Show resolved Hide resolved

cx.editor.autoinfo = Some(Info::new(
title,
help_text
.into_iter()
.map(|(col1, col2)| (col1.to_string(), col2.to_string()))
.collect(),
));
};
}

fn surround_add(cx: &mut Context) {
Expand Down