Add paragraph to last motion (#1956)

Fix #1954
imgbot
Ivan Tham 3 years ago committed by GitHub
parent d3c8286ea0
commit e7beb32fd7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -905,22 +905,26 @@ fn move_next_long_word_end(cx: &mut Context) {
fn move_para_impl<F>(cx: &mut Context, move_fn: F) fn move_para_impl<F>(cx: &mut Context, move_fn: F)
where where
F: Fn(RopeSlice, Range, usize, Movement) -> Range, F: Fn(RopeSlice, Range, usize, Movement) -> Range + 'static,
{ {
let count = cx.count(); let count = cx.count();
let (view, doc) = current!(cx.editor); let motion = move |editor: &mut Editor| {
let text = doc.text().slice(..); let (view, doc) = current!(editor);
let behavior = if doc.mode == Mode::Select { let text = doc.text().slice(..);
Movement::Extend let behavior = if doc.mode == Mode::Select {
} else { Movement::Extend
Movement::Move } else {
}; Movement::Move
};
let selection = doc let selection = doc
.selection(view.id) .selection(view.id)
.clone() .clone()
.transform(|range| move_fn(text, range, count, behavior)); .transform(|range| move_fn(text, range, count, behavior));
doc.set_selection(view.id, selection); doc.set_selection(view.id, selection);
};
motion(cx.editor);
cx.editor.last_motion = Some(Motion(Box::new(motion)));
} }
fn move_prev_paragraph(cx: &mut Context) { fn move_prev_paragraph(cx: &mut Context) {

Loading…
Cancel
Save