@@ -37,7 +37,6 @@ use once_cell::sync::Lazy;
37pub struct Context<'a> {
37pub struct Context<'a> {
38 pub count: usize,
38 pub count: usize,
39 pub editor: &'a mut Editor,
39 pub editor: &'a mut Editor,
42 pub callback: Option<crate::compositor::Callback>,
41 pub callback: Option<crate::compositor::Callback>,
43 pub on_next_key_callback: Option<Box<dyn FnOnce(&mut Context, KeyEvent)>>,
42 pub on_next_key_callback: Option<Box<dyn FnOnce(&mut Context, KeyEvent)>>,
@@ -656,7 +655,7 @@ fn _search(doc: &mut Document, view: &mut View, contents: &str, regex: &Regex, e
657// TODO: use one function for search vs extend
656// TODO: use one function for search vs extend
658pub fn search(cx: &mut Context) {
657pub fn search(cx: &mut Context) {
659− let doc = cx.doc();
658+ let (view, doc) = cx.current();
661 // TODO: could probably share with select_on_matches?
660 // TODO: could probably share with select_on_matches?
@@ -664,7 +663,7 @@ pub fn search(cx: &mut Context) {
664 // feed chunks into the regex yet
663 // feed chunks into the regex yet
665 let contents = doc.text().slice(..).to_string();
664 let contents = doc.text().slice(..).to_string();
667− let view_id = cx.view_id;
666+ let view_id = view.id;
668 let prompt = ui::regex_prompt(cx, "search:".to_string(), move |view, doc, regex| {
667 let prompt = ui::regex_prompt(cx, "search:".to_string(), move |view, doc, regex| {
669 let text = doc.text();
668 let text = doc.text();
670 let start = doc.selection(view.id).cursor();
669 let start = doc.selection(view.id).cursor();
@@ -1739,12 +1738,12 @@ pub mod insert {
1739// storing it?
1738// storing it?
1741pub fn undo(cx: &mut Context) {
1740pub fn undo(cx: &mut Context) {
1742− let view_id = cx.view_id;
1741+ let view_id = cx.view().id;
1743 cx.doc().undo(view_id);
1742 cx.doc().undo(view_id);
1746pub fn redo(cx: &mut Context) {
1745pub fn redo(cx: &mut Context) {
1747− let view_id = cx.view_id;
1746+ let view_id = cx.view().id;
1748 cx.doc().redo(view_id);
1747 cx.doc().redo(view_id);
@@ -2272,8 +2271,9 @@ pub fn space_mode(cx: &mut Context) {
2272 tokio::spawn(doc.save());
2271 tokio::spawn(doc.save());
2274 'c' => {
2273 'c' => {
2274+ let view_id = cx.view().id;
2275 // close current split
2275 // close current split
2276− cx.editor.close(cx.view_id, /* close_buffer */ false);
2276+ cx.editor.close(view_id, /* close_buffer */ false);
2278 // ' ' => toggle_alternate_buffer(cx),
2278 // ' ' => toggle_alternate_buffer(cx),
2279 // TODO: temporary since space mode took it's old key
2279 // TODO: temporary since space mode took it's old key