@@ -40,7 +40,7 @@ use once_cell::sync::Lazy;
41pub struct Context<'a> {
41pub struct Context<'a> {
42 pub register: helix_view::RegisterSelection,
42 pub register: helix_view::RegisterSelection,
43− pub _count: Option<std::num::NonZeroUsize>,
43+ pub count: Option<std::num::NonZeroUsize>,
44 pub editor: &'a mut Editor,
44 pub editor: &'a mut Editor,
46 pub callback: Option<crate::compositor::Callback>,
46 pub callback: Option<crate::compositor::Callback>,
@@ -103,7 +103,7 @@ impl<'a> Context<'a> {
104 #[inline]
104 #[inline]
105 pub fn count(&self) -> usize {
105 pub fn count(&self) -> usize {
106− self._count.map_or(1, |v| v.get())
106+ self.count.map_or(1, |v| v.get())
@@ -315,7 +315,7 @@ pub fn extend_next_word_end(cx: &mut Context) {
318−fn _find_char<F>(cx: &mut Context, search_fn: F, inclusive: bool, extend: bool)
318+fn find_char_impl<F>(cx: &mut Context, search_fn: F, inclusive: bool, extend: bool)
320 // TODO: make an options struct for and abstract this Fn into a searcher type
320 // TODO: make an options struct for and abstract this Fn into a searcher type
321 // use the definition for w/b/e too
321 // use the definition for w/b/e too
@@ -359,7 +359,7 @@ where
361pub fn find_till_char(cx: &mut Context) {
361pub fn find_till_char(cx: &mut Context) {
362− _find_char(
362+ find_char_impl(
364 search::find_nth_next,
364 search::find_nth_next,
365 false, /* inclusive */
365 false, /* inclusive */
@@ -368,7 +368,7 @@ pub fn find_till_char(cx: &mut Context) {
370pub fn find_next_char(cx: &mut Context) {
370pub fn find_next_char(cx: &mut Context) {
371− _find_char(
371+ find_char_impl(
373 search::find_nth_next,
373 search::find_nth_next,
374 true, /* inclusive */
374 true, /* inclusive */
@@ -377,7 +377,7 @@ pub fn find_next_char(cx: &mut Context) {
379pub fn extend_till_char(cx: &mut Context) {
379pub fn extend_till_char(cx: &mut Context) {
380− _find_char(
380+ find_char_impl(
382 search::find_nth_next,
382 search::find_nth_next,
383 false, /* inclusive */
383 false, /* inclusive */
@@ -386,7 +386,7 @@ pub fn extend_till_char(cx: &mut Context) {
388pub fn extend_next_char(cx: &mut Context) {
388pub fn extend_next_char(cx: &mut Context) {
389− _find_char(
389+ find_char_impl(
391 search::find_nth_next,
391 search::find_nth_next,
392 true, /* inclusive */
392 true, /* inclusive */
@@ -395,7 +395,7 @@ pub fn extend_next_char(cx: &mut Context) {
397pub fn till_prev_char(cx: &mut Context) {
397pub fn till_prev_char(cx: &mut Context) {
398− _find_char(
398+ find_char_impl(
400 search::find_nth_prev,
400 search::find_nth_prev,
401 false, /* inclusive */
401 false, /* inclusive */
@@ -404,7 +404,7 @@ pub fn till_prev_char(cx: &mut Context) {
406pub fn find_prev_char(cx: &mut Context) {
406pub fn find_prev_char(cx: &mut Context) {
407− _find_char(
407+ find_char_impl(
409 search::find_nth_prev,
409 search::find_nth_prev,
410 true, /* inclusive */
410 true, /* inclusive */
@@ -413,7 +413,7 @@ pub fn find_prev_char(cx: &mut Context) {
415pub fn extend_till_prev_char(cx: &mut Context) {
415pub fn extend_till_prev_char(cx: &mut Context) {
416− _find_char(
416+ find_char_impl(
418 search::find_nth_prev,
418 search::find_nth_prev,
419 false, /* inclusive */
419 false, /* inclusive */
@@ -422,7 +422,7 @@ pub fn extend_till_prev_char(cx: &mut Context) {
424pub fn extend_prev_char(cx: &mut Context) {
424pub fn extend_prev_char(cx: &mut Context) {
425− _find_char(
425+ find_char_impl(
427 search::find_nth_prev,
427 search::find_nth_prev,
428 true, /* inclusive */
428 true, /* inclusive */
@@ -669,7 +669,7 @@ pub fn split_selection_on_newline(cx: &mut Context) {
669// I'd probably collect all the matches right now and store the current index. The cache needs
669// I'd probably collect all the matches right now and store the current index. The cache needs
670// wiping if input happens.
670// wiping if input happens.
672−fn _search(doc: &mut Document, view: &mut View, contents: &str, regex: &Regex, extend: bool) {
672+fn search_impl(doc: &mut Document, view: &mut View, contents: &str, regex: &Regex, extend: bool) {
673 let text = doc.text();
673 let text = doc.text();
674 let selection = doc.selection(view.id);
674 let selection = doc.selection(view.id);
675 let start = text.char_to_byte(selection.cursor());
675 let start = text.char_to_byte(selection.cursor());
@@ -715,8 +715,7 @@ pub fn search(cx: &mut Context) {
716 let view_id = view.id;
716 let view_id = view.id;
717 let prompt = ui::regex_prompt(cx, "search:".to_string(), move |view, doc, regex| {
717 let prompt = ui::regex_prompt(cx, "search:".to_string(), move |view, doc, regex| {
718− _search(doc, view, &contents, ®ex, false);
718+ search_impl(doc, view, &contents, ®ex, false);
720 // TODO: only store on enter (accept), not update
719 // TODO: only store on enter (accept), not update
721 register::set('\\', vec![regex.as_str().to_string()]);
720 register::set('\\', vec![regex.as_str().to_string()]);
@@ -725,22 +724,22 @@ pub fn search(cx: &mut Context) {
726// can't search next for ""compose"" for some reason
725// can't search next for ""compose"" for some reason
728−pub fn _search_next(cx: &mut Context, extend: bool) {
727+pub fn search_next_impl(cx: &mut Context, extend: bool) {
729 if let Some(query) = register::get('\\') {
728 if let Some(query) = register::get('\\') {
730 let query = query.first().unwrap();
729 let query = query.first().unwrap();
731 let (view, doc) = cx.current();
730 let (view, doc) = cx.current();
732 let contents = doc.text().slice(..).to_string();
731 let contents = doc.text().slice(..).to_string();
733 let regex = Regex::new(query).unwrap();
732 let regex = Regex::new(query).unwrap();
734− _search(doc, view, &contents, ®ex, extend);
733+ search_impl(doc, view, &contents, ®ex, extend);
738pub fn search_next(cx: &mut Context) {
737pub fn search_next(cx: &mut Context) {
739− _search_next(cx, false);
738+ search_next_impl(cx, false);
742pub fn extend_search_next(cx: &mut Context) {
741pub fn extend_search_next(cx: &mut Context) {
743− _search_next(cx, true);
742+ search_next_impl(cx, true);
746pub fn search_selection(cx: &mut Context) {
745pub fn search_selection(cx: &mut Context) {
@@ -795,7 +794,7 @@ pub fn extend_line(cx: &mut Context) {
796// heuristic: append changes to history after each command, unless we're in insert mode
795// heuristic: append changes to history after each command, unless we're in insert mode
798−fn _delete_selection(reg: char, doc: &mut Document, view_id: ViewId) {
797+fn delete_selection_impl(reg: char, doc: &mut Document, view_id: ViewId) {
799 // first yank the selection
798 // first yank the selection
800 let values: Vec<String> = doc
799 let values: Vec<String> = doc
801 .selection(view_id)
800 .selection(view_id)
@@ -818,7 +817,7 @@ fn _delete_selection(reg: char, doc: &mut Document, view_id: ViewId) {
818pub fn delete_selection(cx: &mut Context) {
817pub fn delete_selection(cx: &mut Context) {
819 let reg = cx.register.name();
818 let reg = cx.register.name();
820 let (view, doc) = cx.current();
819 let (view, doc) = cx.current();
821− _delete_selection(reg, doc, view.id);
820+ delete_selection_impl(reg, doc, view.id);
823 doc.append_changes_to_history(view.id);
822 doc.append_changes_to_history(view.id);
@@ -829,7 +828,7 @@ pub fn delete_selection(cx: &mut Context) {
829pub fn change_selection(cx: &mut Context) {
828pub fn change_selection(cx: &mut Context) {
830 let reg = cx.register.name();
829 let reg = cx.register.name();
831 let (view, doc) = cx.current();
830 let (view, doc) = cx.current();
832− _delete_selection(reg, doc, view.id);
831+ delete_selection_impl(reg, doc, view.id);
833 enter_insert_mode(doc);
832 enter_insert_mode(doc);
@@ -912,7 +911,7 @@ mod cmd {
913 fn quit(editor: &mut Editor, args: &[&str], event: PromptEvent) {
912 fn quit(editor: &mut Editor, args: &[&str], event: PromptEvent) {
914 // last view and we have unsaved changes
913 // last view and we have unsaved changes
915− if editor.tree.views().count() == 1 && _buffers_remaining(editor) {
914+ if editor.tree.views().count() == 1 && buffers_remaining_impl(editor) {
918 editor.close(editor.view().id, /* close_buffer */ false);
917 editor.close(editor.view().id, /* close_buffer */ false);
@@ -934,7 +933,7 @@ mod cmd {
937− fn _write<P: AsRef<Path>>(
936+ fn write_impl<P: AsRef<Path>>(
938 view: &View,
937 view: &View,
939 doc: &mut Document,
938 doc: &mut Document,
940 path: Option<P>,
939 path: Option<P>,
@@ -962,7 +961,7 @@ mod cmd {
963 fn write(editor: &mut Editor, args: &[&str], event: PromptEvent) {
962 fn write(editor: &mut Editor, args: &[&str], event: PromptEvent) {
964 let (view, doc) = editor.current();
963 let (view, doc) = editor.current();
965− if let Err(e) = _write(view, doc, args.first()) {
964+ if let Err(e) = write_impl(view, doc, args.first()) {
966 editor.set_error(e.to_string());
965 editor.set_error(e.to_string());
@@ -1039,7 +1038,7 @@ mod cmd {
1040 fn write_quit(editor: &mut Editor, args: &[&str], event: PromptEvent) {
1039 fn write_quit(editor: &mut Editor, args: &[&str], event: PromptEvent) {
1041 let (view, doc) = editor.current();
1040 let (view, doc) = editor.current();
1042− if let Err(e) = _write(view, doc, args.first()) {
1041+ if let Err(e) = write_impl(view, doc, args.first()) {
1043 editor.set_error(e.to_string());
1042 editor.set_error(e.to_string());
@@ -1053,7 +1052,7 @@ mod cmd {
1054 /// Returns `true` if there are modified buffers remaining and sets editor error,
1053 /// Returns `true` if there are modified buffers remaining and sets editor error,
1055 /// otherwise returns `false`
1054 /// otherwise returns `false`
1056− fn _buffers_remaining(editor: &mut Editor) -> bool {
1055+ fn buffers_remaining_impl(editor: &mut Editor) -> bool {
1057 let modified: Vec<_> = editor
1056 let modified: Vec<_> = editor
1058 .documents()
1057 .documents()
1059 .filter(|doc| doc.is_modified())
1058 .filter(|doc| doc.is_modified())
@@ -1076,7 +1075,13 @@ mod cmd {
1079− fn _write_all(editor: &mut Editor, args: &[&str], event: PromptEvent, quit: bool, force: bool) {
1078+ fn write_all_impl(
1079+ editor: &mut Editor,
1081+ event: PromptEvent,
1080 let mut errors = String::new();
1085 let mut errors = String::new();
1082 // save all documents
1087 // save all documents
@@ -1090,7 +1095,7 @@ mod cmd {
1090 editor.set_error(errors);
1095 editor.set_error(errors);
1092 if quit {
1097 if quit {
1093− if !force && _buffers_remaining(editor) {
1098+ if !force && buffers_remaining_impl(editor) {
@@ -1103,19 +1108,19 @@ mod cmd {
1105 fn write_all(editor: &mut Editor, args: &[&str], event: PromptEvent) {
1110 fn write_all(editor: &mut Editor, args: &[&str], event: PromptEvent) {
1106− _write_all(editor, args, event, false, false)
1111+ write_all_impl(editor, args, event, false, false)
1109 fn write_all_quit(editor: &mut Editor, args: &[&str], event: PromptEvent) {
1114 fn write_all_quit(editor: &mut Editor, args: &[&str], event: PromptEvent) {
1110− _write_all(editor, args, event, true, false)
1115+ write_all_impl(editor, args, event, true, false)
1113 fn force_write_all_quit(editor: &mut Editor, args: &[&str], event: PromptEvent) {
1118 fn force_write_all_quit(editor: &mut Editor, args: &[&str], event: PromptEvent) {
1114− _write_all(editor, args, event, true, true)
1119+ write_all_impl(editor, args, event, true, true)
1117− fn _quit_all(editor: &mut Editor, args: &[&str], event: PromptEvent, force: bool) {
1122+ fn quit_all_impl(editor: &mut Editor, args: &[&str], event: PromptEvent, force: bool) {
1118− if !force && _buffers_remaining(editor) {
1123+ if !force && buffers_remaining_impl(editor) {
@@ -1127,11 +1132,11 @@ mod cmd {
1129 fn quit_all(editor: &mut Editor, args: &[&str], event: PromptEvent) {
1134 fn quit_all(editor: &mut Editor, args: &[&str], event: PromptEvent) {
1130− _quit_all(editor, args, event, false)
1135+ quit_all_impl(editor, args, event, false)
1133 fn force_quit_all(editor: &mut Editor, args: &[&str], event: PromptEvent) {
1138 fn force_quit_all(editor: &mut Editor, args: &[&str], event: PromptEvent) {
1134− _quit_all(editor, args, event, true)
1139+ quit_all_impl(editor, args, event, true)
1137 pub const COMMAND_LIST: &[Command] = &[
1142 pub const COMMAND_LIST: &[Command] = &[
@@ -1578,7 +1583,7 @@ fn switch_to_last_accessed_file(cx: &mut Context) {
1580pub fn goto_mode(cx: &mut Context) {
1585pub fn goto_mode(cx: &mut Context) {
1581− if let Some(count) = cx._count {
1586+ if let Some(count) = cx.count {
1582 push_jump(cx.editor);
1587 push_jump(cx.editor);
1584 let (view, doc) = cx.current();
1589 let (view, doc) = cx.current();
@@ -1646,7 +1651,7 @@ pub fn exit_select_mode(cx: &mut Context) {
1646 cx.doc().mode = Mode::Normal;
1651 cx.doc().mode = Mode::Normal;
1649−fn _goto(
1654+fn goto_impl(
1650 editor: &mut Editor,
1655 editor: &mut Editor,
1651 compositor: &mut Compositor,
1656 compositor: &mut Compositor,
1652 locations: Vec<lsp::Location>,
1657 locations: Vec<lsp::Location>,
@@ -1734,7 +1739,7 @@ pub fn goto_definition(cx: &mut Context) {
1734 None => Vec::new(),
1739 None => Vec::new(),
1737− _goto(editor, compositor, items, offset_encoding);
1742+ goto_impl(editor, compositor, items, offset_encoding);
@@ -1771,7 +1776,7 @@ pub fn goto_type_definition(cx: &mut Context) {
1771 None => Vec::new(),
1776 None => Vec::new(),
1774− _goto(editor, compositor, items, offset_encoding);
1779+ goto_impl(editor, compositor, items, offset_encoding);
@@ -1808,7 +1813,7 @@ pub fn goto_implementation(cx: &mut Context) {
1808 None => Vec::new(),
1813 None => Vec::new(),
1811− _goto(editor, compositor, items, offset_encoding);
1816+ goto_impl(editor, compositor, items, offset_encoding);
@@ -1832,7 +1837,7 @@ pub fn goto_reference(cx: &mut Context) {
1832 move |editor: &mut Editor,
1837 move |editor: &mut Editor,
1833 compositor: &mut Compositor,
1838 compositor: &mut Compositor,
1834 items: Option<Vec<lsp::Location>>| {
1839 items: Option<Vec<lsp::Location>>| {
1835− _goto(
1840+ goto_impl(
1837 compositor,
1842 compositor,
1838 items.unwrap_or_default(),
1843 items.unwrap_or_default(),
@@ -2236,7 +2241,7 @@ enum Paste {
2239−fn _paste(reg: char, doc: &mut Document, view: &View, action: Paste) -> Option<Transaction> {
2244+fn paste_impl(reg: char, doc: &mut Document, view: &View, action: Paste) -> Option<Transaction> {
2240 if let Some(values) = register::get(reg) {
2245 if let Some(values) = register::get(reg) {
2241 let repeat = std::iter::repeat(
2246 let repeat = std::iter::repeat(
@@ -2305,7 +2310,7 @@ pub fn paste_after(cx: &mut Context) {
2305 let reg = cx.register.name();
2310 let reg = cx.register.name();
2306 let (view, doc) = cx.current();
2311 let (view, doc) = cx.current();
2308− if let Some(transaction) = _paste(reg, doc, view, Paste::After) {
2313+ if let Some(transaction) = paste_impl(reg, doc, view, Paste::After) {
2309 doc.apply(&transaction, view.id);
2314 doc.apply(&transaction, view.id);
2310 doc.append_changes_to_history(view.id);
2315 doc.append_changes_to_history(view.id);
@@ -2315,7 +2320,7 @@ pub fn paste_before(cx: &mut Context) {
2315 let reg = cx.register.name();
2320 let reg = cx.register.name();
2316 let (view, doc) = cx.current();
2321 let (view, doc) = cx.current();
2318− if let Some(transaction) = _paste(reg, doc, view, Paste::Before) {
2323+ if let Some(transaction) = paste_impl(reg, doc, view, Paste::Before) {
2319 doc.apply(&transaction, view.id);
2324 doc.apply(&transaction, view.id);
2320 doc.append_changes_to_history(view.id);
2325 doc.append_changes_to_history(view.id);