@@ -4886,17 +4886,19 @@ fn transpose_view(cx: &mut Context) {
48864886 cx.editor.transpose_view()
48874887}
48884888
4889−// split helper, clear it later
4890−fn split(cx: &mut Context, action: Action) {
4891− let (view, doc) = current!(cx.editor);
4889+/// Open a new split in the given direction specified by the action.
4890+///
4891+/// Maintain the current view (both the cursor's position and view in document).
4892+fn split(editor: &mut Editor, action: Action) {
4893+ let (view, doc) = current!(editor);
48924894 let id = doc.id();
48934895 let selection = doc.selection(view.id).clone();
48944896 let offset = view.offset;
48954897
4896− cx.editor.switch(id, action);
4898+ editor.switch(id, action);
48974899
48984900 // match the selection in the previous view
4899− let (view, doc) = current!(cx.editor);
4901+ let (view, doc) = current!(editor);
49004902 doc.set_selection(view.id, selection);
49014903 // match the view scroll offset (switch doesn't handle this fully
49024904 // since the selection is only matched after the split)
@@ -4904,7 +4906,7 @@ fn split(cx: &mut Context, action: Action) {
49044906}
49054907
49064908fn hsplit(cx: &mut Context) {
4907− split(cx, Action::HorizontalSplit);
4909+ split(cx.editor, Action::HorizontalSplit);
49084910}
49094911
49104912fn hsplit_new(cx: &mut Context) {
@@ -4912,7 +4914,7 @@ fn hsplit_new(cx: &mut Context) {
49124914}
49134915
49144916fn vsplit(cx: &mut Context) {
4915− split(cx, Action::VerticalSplit);
4917+ split(cx.editor, Action::VerticalSplit);
49164918}
49174919
49184920fn vsplit_new(cx: &mut Context) {