on master help sign in
Drop cx.view_id, it was used before we had cx.current.
fae2127Blaž Hrastnik
helix-term/src/commands.rs+6−6
@@ -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,
40− pub view_id: ViewId,
41
40
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
656
655
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();
660
659
661 // TODO: could probably share with select_on_matches?
660 // TODO: could probably share with select_on_matches?
662
661
@@ -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();
666
665
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?
1740
1739
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);
1744}
1743}
1745
1744
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);
1749}
1748}
1750
1749
@@ -2272,8 +2271,9 @@ pub fn space_mode(cx: &mut Context) {
2272 tokio::spawn(doc.save());
2271 tokio::spawn(doc.save());
2273 }
2272 }
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);
2277 }
2277 }
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
helix-term/src/ui/editor.rs−1
@@ -530,7 +530,6 @@ impl Component for EditorView {
530 let mode = doc.mode();
530 let mode = doc.mode();
531
531
532 let mut cxt = commands::Context {
532 let mut cxt = commands::Context {
533− view_id: view.id,
534 editor: &mut cx.editor,
533 editor: &mut cx.editor,
535 count: 1,
534 count: 1,
536 callback: None,
535 callback: None,