|
|
@ -38,7 +38,7 @@ use helix_core::{
|
|
|
|
textobject,
|
|
|
|
textobject,
|
|
|
|
unicode::width::UnicodeWidthChar,
|
|
|
|
unicode::width::UnicodeWidthChar,
|
|
|
|
visual_offset_from_block, Deletion, LineEnding, Position, Range, Rope, RopeGraphemes,
|
|
|
|
visual_offset_from_block, Deletion, LineEnding, Position, Range, Rope, RopeGraphemes,
|
|
|
|
RopeReader, RopeSlice, Selection, SmallVec, Tendril, Transaction,
|
|
|
|
RopeReader, RopeSlice, Selection, SmallVec, Syntax, Tendril, Transaction,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
use helix_view::{
|
|
|
|
use helix_view::{
|
|
|
|
document::{FormatterError, Mode, SCRATCH_BUFFER_NAME},
|
|
|
|
document::{FormatterError, Mode, SCRATCH_BUFFER_NAME},
|
|
|
@ -4976,17 +4976,23 @@ pub fn extend_parent_node_start(cx: &mut Context) {
|
|
|
|
move_node_bound_impl(cx, Direction::Backward, Movement::Extend)
|
|
|
|
move_node_bound_impl(cx, Direction::Backward, Movement::Extend)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn select_all_siblings(cx: &mut Context) {
|
|
|
|
fn select_all_impl<F>(editor: &mut Editor, select_fn: F)
|
|
|
|
let motion = |editor: &mut Editor| {
|
|
|
|
where
|
|
|
|
|
|
|
|
F: Fn(&Syntax, RopeSlice, Selection) -> Selection,
|
|
|
|
|
|
|
|
{
|
|
|
|
let (view, doc) = current!(editor);
|
|
|
|
let (view, doc) = current!(editor);
|
|
|
|
|
|
|
|
|
|
|
|
if let Some(syntax) = doc.syntax() {
|
|
|
|
if let Some(syntax) = doc.syntax() {
|
|
|
|
let text = doc.text().slice(..);
|
|
|
|
let text = doc.text().slice(..);
|
|
|
|
let current_selection = doc.selection(view.id);
|
|
|
|
let current_selection = doc.selection(view.id);
|
|
|
|
let selection =
|
|
|
|
let selection = select_fn(syntax, text, current_selection.clone());
|
|
|
|
object::select_all_siblings(syntax.tree(), text, current_selection.clone());
|
|
|
|
|
|
|
|
doc.set_selection(view.id, selection);
|
|
|
|
doc.set_selection(view.id, selection);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn select_all_siblings(cx: &mut Context) {
|
|
|
|
|
|
|
|
let motion = |editor: &mut Editor| {
|
|
|
|
|
|
|
|
select_all_impl(editor, object::select_all_siblings);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
cx.editor.apply_motion(motion);
|
|
|
|
cx.editor.apply_motion(motion);
|
|
|
@ -4994,19 +5000,10 @@ fn select_all_siblings(cx: &mut Context) {
|
|
|
|
|
|
|
|
|
|
|
|
fn select_all_children(cx: &mut Context) {
|
|
|
|
fn select_all_children(cx: &mut Context) {
|
|
|
|
let motion = |editor: &mut Editor| {
|
|
|
|
let motion = |editor: &mut Editor| {
|
|
|
|
let (view, doc) = current!(editor);
|
|
|
|
select_all_impl(editor, object::select_all_children);
|
|
|
|
|
|
|
|
|
|
|
|
if let Some(syntax) = doc.syntax() {
|
|
|
|
|
|
|
|
let text = doc.text().slice(..);
|
|
|
|
|
|
|
|
let current_selection = doc.selection(view.id);
|
|
|
|
|
|
|
|
let selection =
|
|
|
|
|
|
|
|
object::select_all_children(syntax.tree(), text, current_selection.clone());
|
|
|
|
|
|
|
|
doc.set_selection(view.id, selection);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
motion(cx.editor);
|
|
|
|
cx.editor.apply_motion(motion);
|
|
|
|
cx.editor.last_motion = Some(Motion(Box::new(motion)));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn match_brackets(cx: &mut Context) {
|
|
|
|
fn match_brackets(cx: &mut Context) {
|
|
|
@ -6040,7 +6037,10 @@ fn jump_to_label(cx: &mut Context, labels: Vec<Range>, behaviour: Movement) {
|
|
|
|
let doc = doc.id();
|
|
|
|
let doc = doc.id();
|
|
|
|
cx.on_next_key(move |cx, event| {
|
|
|
|
cx.on_next_key(move |cx, event| {
|
|
|
|
let alphabet = &cx.editor.config().jump_label_alphabet;
|
|
|
|
let alphabet = &cx.editor.config().jump_label_alphabet;
|
|
|
|
let Some(i ) = event.char().and_then(|ch| alphabet.iter().position(|&it| it == ch)) else {
|
|
|
|
let Some(i) = event
|
|
|
|
|
|
|
|
.char()
|
|
|
|
|
|
|
|
.and_then(|ch| alphabet.iter().position(|&it| it == ch))
|
|
|
|
|
|
|
|
else {
|
|
|
|
doc_mut!(cx.editor, &doc).remove_jump_labels(view);
|
|
|
|
doc_mut!(cx.editor, &doc).remove_jump_labels(view);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
};
|
|
|
|
};
|
|
|
@ -6053,7 +6053,10 @@ fn jump_to_label(cx: &mut Context, labels: Vec<Range>, behaviour: Movement) {
|
|
|
|
cx.on_next_key(move |cx, event| {
|
|
|
|
cx.on_next_key(move |cx, event| {
|
|
|
|
doc_mut!(cx.editor, &doc).remove_jump_labels(view);
|
|
|
|
doc_mut!(cx.editor, &doc).remove_jump_labels(view);
|
|
|
|
let alphabet = &cx.editor.config().jump_label_alphabet;
|
|
|
|
let alphabet = &cx.editor.config().jump_label_alphabet;
|
|
|
|
let Some(inner ) = event.char().and_then(|ch| alphabet.iter().position(|&it| it == ch)) else {
|
|
|
|
let Some(inner) = event
|
|
|
|
|
|
|
|
.char()
|
|
|
|
|
|
|
|
.and_then(|ch| alphabet.iter().position(|&it| it == ch))
|
|
|
|
|
|
|
|
else {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
if let Some(mut range) = labels.get(outer + inner).copied() {
|
|
|
|
if let Some(mut range) = labels.get(outer + inner).copied() {
|
|
|
@ -6074,7 +6077,7 @@ fn jump_to_label(cx: &mut Context, labels: Vec<Range>, behaviour: Movement) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
Range::new(anchor, range.head)
|
|
|
|
Range::new(anchor, range.head)
|
|
|
|
}else{
|
|
|
|
} else {
|
|
|
|
range.with_direction(Direction::Forward)
|
|
|
|
range.with_direction(Direction::Forward)
|
|
|
|
};
|
|
|
|
};
|
|
|
|
doc_mut!(cx.editor, &doc).set_selection(view, range.into());
|
|
|
|
doc_mut!(cx.editor, &doc).set_selection(view, range.into());
|
|
|
|