on master help sign in
Merge branch 'master' into great_line_ending_and_cursor_range_cleanup
4359404Nathan Vegdahl
helix-core/src/syntax.rs−1
@@ -95,7 +95,6 @@ fn load_runtime_file(language: &str, filename: &str) -> Result<String, std::io::
95
95
96#[cfg(feature = "embed_runtime")]
96#[cfg(feature = "embed_runtime")]
97fn load_runtime_file(language: &str, filename: &str) -> Result<String, Box<dyn std::error::Error>> {
97fn load_runtime_file(language: &str, filename: &str) -> Result<String, Box<dyn std::error::Error>> {
98− use std::fmt;
99 use std::path::PathBuf;
98 use std::path::PathBuf;
100
99
101 #[derive(rust_embed::RustEmbed)]
100 #[derive(rust_embed::RustEmbed)]
helix-syntax/src/lib.rs+1−9
@@ -3,15 +3,7 @@ use libloading::{Library, Symbol};
3use tree_sitter::Language;
3use tree_sitter::Language;
4
4
5fn replace_dashes_with_underscores(name: &str) -> String {
5fn replace_dashes_with_underscores(name: &str) -> String {
6− let mut result = String::with_capacity(name.len());
6+ name.replace('-', "_")
7− for c in name.chars() {
8− if c == '-' {
9− result.push('_');
10− } else {
11− result.push(c);
12− }
13− }
14− result
15}
7}
16#[cfg(unix)]
8#[cfg(unix)]
17const DYLIB_EXTENSION: &str = "so";
9const DYLIB_EXTENSION: &str = "so";
helix-term/src/commands.rs+14
@@ -214,6 +214,7 @@ impl Command {
214 file_picker,
214 file_picker,
215 buffer_picker,
215 buffer_picker,
216 symbol_picker,
216 symbol_picker,
217+ last_picker,
217 prepend_to_line,
218 prepend_to_line,
218 append_to_line,
219 append_to_line,
219 open_below,
220 open_below,
@@ -2127,6 +2128,17 @@ fn symbol_picker(cx: &mut Context) {
2127 )
2128 )
2128}
2129}
2129
2130
2131+fn last_picker(cx: &mut Context) {
2132+ // TODO: last picker does not seemed to work well with buffer_picker
2133+ cx.callback = Some(Box::new(|compositor: &mut Compositor| {
2134+ if let Some(picker) = compositor.last_picker.take() {
2135+ compositor.push(picker);
2136+ }
2137+ // XXX: figure out how to show error when no last picker lifetime
2138+ // cx.editor.set_error("no last picker".to_owned())
2139+ }));
2140+}
2141+
2130// I inserts at the first nonwhitespace character of each line with a selection
2142// I inserts at the first nonwhitespace character of each line with a selection
2131fn prepend_to_line(cx: &mut Context) {
2143fn prepend_to_line(cx: &mut Context) {
2132 goto_first_nonwhitespace(cx);
2144 goto_first_nonwhitespace(cx);
@@ -3837,6 +3849,8 @@ macro_rules! mode_info {
3837mode_info! {
3849mode_info! {
3838 /// space mode
3850 /// space mode
3839 space_mode, SPACE_MODE,
3851 space_mode, SPACE_MODE,
3852+ /// resume last picker
3853+ "'" => last_picker,
3840 /// file picker
3854 /// file picker
3841 "f" => file_picker,
3855 "f" => file_picker,
3842 /// buffer picker
3856 /// buffer picker
helix-term/src/compositor.rs+5−2
@@ -74,6 +74,8 @@ type Terminal = tui::terminal::Terminal<CrosstermBackend<std::io::Stdout>>;
74pub struct Compositor {
74pub struct Compositor {
75 layers: Vec<Box<dyn Component>>,
75 layers: Vec<Box<dyn Component>>,
76 terminal: Terminal,
76 terminal: Terminal,
77+
78+ pub(crate) last_picker: Option<Box<dyn Component>>,
77}
79}
78
80
79impl Compositor {
81impl Compositor {
@@ -83,6 +85,7 @@ impl Compositor {
83 Ok(Self {
85 Ok(Self {
84 layers: Vec::new(),
86 layers: Vec::new(),
85 terminal,
87 terminal,
88+ last_picker: None,
86 })
89 })
87 }
90 }
88
91
@@ -103,8 +106,8 @@ impl Compositor {
103 self.layers.push(layer);
106 self.layers.push(layer);
104 }
107 }
105
108
106− pub fn pop(&mut self) {
109+ pub fn pop(&mut self) -> Option<Box<dyn Component>> {
107− self.layers.pop();
110+ self.layers.pop()
108 }
111 }
109
112
110 pub fn handle_event(&mut self, event: Event, cx: &mut Context) -> bool {
113 pub fn handle_event(&mut self, event: Event, cx: &mut Context) -> bool {
helix-term/src/ui/menu.rs+7−9
@@ -90,13 +90,13 @@ impl<T: Item> Menu<T> {
90
90
91 pub fn move_up(&mut self) {
91 pub fn move_up(&mut self) {
92 // TODO: wrap around to end
92 // TODO: wrap around to end
93− let pos = self.cursor.map_or(0, |i| i.saturating_sub(1)) % self.options.len();
93+ let pos = self.cursor.map_or(0, |i| i.saturating_sub(1)) % self.matches.len();
94 self.cursor = Some(pos);
94 self.cursor = Some(pos);
95 self.adjust_scroll();
95 self.adjust_scroll();
96 }
96 }
97
97
98 pub fn move_down(&mut self) {
98 pub fn move_down(&mut self) {
99− let pos = self.cursor.map_or(0, |i| i + 1) % self.options.len();
99+ let pos = self.cursor.map_or(0, |i| i + 1) % self.matches.len();
100 self.cursor = Some(pos);
100 self.cursor = Some(pos);
101 self.adjust_scroll();
101 self.adjust_scroll();
102 }
102 }
@@ -233,16 +233,16 @@ impl<T: Item + 'static> Component for Menu<T> {
233 let max_lens = self.options.iter().fold(vec![0; n], |mut acc, option| {
233 let max_lens = self.options.iter().fold(vec![0; n], |mut acc, option| {
234 let row = option.row();
234 let row = option.row();
235 // maintain max for each column
235 // maintain max for each column
236− for (i, cell) in row.cells.iter().enumerate() {
236+ for (acc, cell) in acc.iter_mut().zip(row.cells.iter()) {
237 let width = cell.content.width();
237 let width = cell.content.width();
238− if width > acc[i] {
238+ if width > *acc {
239− acc[i] = width;
239+ *acc = width;
240 }
240 }
241 }
241 }
242
242
243 acc
243 acc
244 });
244 });
245− let len = (max_lens.iter().sum::<usize>()) + n + 1; // +1: reserve some space for scrollbar
245+ let len = max_lens.iter().sum::<usize>() + n + 1; // +1: reserve some space for scrollbar
246 let width = len.min(viewport.0 as usize);
246 let width = len.min(viewport.0 as usize);
247
247
248 self.widths = max_lens
248 self.widths = max_lens
@@ -250,9 +250,7 @@ impl<T: Item + 'static> Component for Menu<T> {
250 .map(|len| Constraint::Length(len as u16))
250 .map(|len| Constraint::Length(len as u16))
251 .collect();
251 .collect();
252
252
253− const MAX: usize = 10;
254− let height = std::cmp::min(self.options.len(), MAX);
253+ let height = self.options.len().min(10).min(viewport.1 as usize);
255− let height = std::cmp::min(height, viewport.1 as usize);
256
254
257 self.size = (width as u16, height as u16);
255 self.size = (width as u16, height as u16);
258
256
helix-term/src/ui/picker.rs+1−1
@@ -159,7 +159,7 @@ impl<T: 'static> Component for Picker<T> {
159
159
160 let close_fn = EventResult::Consumed(Some(Box::new(|compositor: &mut Compositor| {
160 let close_fn = EventResult::Consumed(Some(Box::new(|compositor: &mut Compositor| {
161 // remove the layer
161 // remove the layer
162− compositor.pop();
162+ compositor.last_picker = compositor.pop();
163 })));
163 })));
164
164
165 match key_event {
165 match key_event {
helix-term/src/ui/prompt.rs+1−1
@@ -463,7 +463,7 @@ impl Component for Prompt {
463 code: KeyCode::Enter,
463 code: KeyCode::Enter,
464 ..
464 ..
465 } => {
465 } => {
466− if self.line.ends_with('/') {
466+ if self.selection.is_some() && self.line.ends_with('/') {
467 self.completion = (self.completion_fn)(&self.line);
467 self.completion = (self.completion_fn)(&self.line);
468 self.exit_selection();
468 self.exit_selection();
469 } else {
469 } else {
helix-view/src/document.rs+1
@@ -596,6 +596,7 @@ impl Document {
596 let transaction = helix_core::diff::compare_ropes(self.text(), &rope);
596 let transaction = helix_core::diff::compare_ropes(self.text(), &rope);
597 self.apply(&transaction, view_id);
597 self.apply(&transaction, view_id);
598 self.append_changes_to_history(view_id);
598 self.append_changes_to_history(view_id);
599+ self.reset_modified();
599
600
600 // Detect indentation style and line ending.
601 // Detect indentation style and line ending.
601 self.detect_indent_style();
602 self.detect_indent_style();
runtime/themes/dark_plus.toml+2−2
@@ -46,10 +46,10 @@
46
46
47"ui.cursor" = { fg = "cursor", modifiers = ["reversed"] }
47"ui.cursor" = { fg = "cursor", modifiers = ["reversed"] }
48"ui.cursor.primary" = { fg = "cursor", modifiers = ["reversed"] }
48"ui.cursor.primary" = { fg = "cursor", modifiers = ["reversed"] }
49−"ui.cursor.match" = { fg = "cursor", modifiers = ['underlined'] }
49+"ui.cursor.match" = { bg = "#3a3d41", modifiers = ["underlined"] }
50
50
51"ui.selection" = { bg = "#3a3d41" }
51"ui.selection" = { bg = "#3a3d41" }
52−"ui.selection.primary" = { bg = "#add6ff26" }
52+"ui.selection.primary" = { bg = "#264f78" }
53
53
54"ui.linenr" = { fg = "#858585" }
54"ui.linenr" = { fg = "#858585" }
55"ui.linenr.selected" = { fg = "#c6c6c6" }
55"ui.linenr.selected" = { fg = "#c6c6c6" }
rustfmt.tomlnew file

No changes to the content.