@@ -4886,17 +4886,19 @@ fn transpose_view(cx: &mut Context) {
4886 cx.editor.transpose_view()
4886 cx.editor.transpose_view()
4889−// split helper, clear it later
4889+/// Open a new split in the given direction specified by the action.
4891+/// Maintain the current view (both the cursor's position and view in document).
4890−fn split(cx: &mut Context, action: Action) {
4892+fn split(editor: &mut Editor, action: Action) {
4891− let (view, doc) = current!(cx.editor);
4893+ let (view, doc) = current!(editor);
4892 let id = doc.id();
4894 let id = doc.id();
4893 let selection = doc.selection(view.id).clone();
4895 let selection = doc.selection(view.id).clone();
4894 let offset = view.offset;
4896 let offset = view.offset;
4896− cx.editor.switch(id, action);
4898+ editor.switch(id, action);
4898 // match the selection in the previous view
4900 // match the selection in the previous view
4899− let (view, doc) = current!(cx.editor);
4901+ let (view, doc) = current!(editor);
4900 doc.set_selection(view.id, selection);
4902 doc.set_selection(view.id, selection);
4901 // match the view scroll offset (switch doesn't handle this fully
4903 // match the view scroll offset (switch doesn't handle this fully
4902 // since the selection is only matched after the split)
4904 // since the selection is only matched after the split)
@@ -4904,7 +4906,7 @@ fn split(cx: &mut Context, action: Action) {
4906fn hsplit(cx: &mut Context) {
4908fn hsplit(cx: &mut Context) {
4907− split(cx, Action::HorizontalSplit);
4909+ split(cx.editor, Action::HorizontalSplit);
4910fn hsplit_new(cx: &mut Context) {
4912fn hsplit_new(cx: &mut Context) {
@@ -4912,7 +4914,7 @@ fn hsplit_new(cx: &mut Context) {
4914fn vsplit(cx: &mut Context) {
4916fn vsplit(cx: &mut Context) {
4915− split(cx, Action::VerticalSplit);
4917+ split(cx.editor, Action::VerticalSplit);
4918fn vsplit_new(cx: &mut Context) {
4920fn vsplit_new(cx: &mut Context) {