on master help sign in
Fix unused variable, parameter, and `mut` warnings in helix-term.
commitefa3389b6aa4e07982e1e902b0173d1daa4a301e authorNathan Vegdahl <cessen@cessen.com> dateThu 1 Jul 2021, 11:57 (5 years ago) parent702a049
12 files changed+112−118
helix-term/src/application.rs+11−8 helix-term/src/commands.rs+56−58 helix-term/src/compositor.rs+5−6 helix-term/src/ui/completion.rs+1−1 helix-term/src/ui/editor.rs+4−5 helix-term/src/ui/markdown.rs+5−5 helix-term/src/ui/menu.rs+1−2 helix-term/src/ui/mod.rs+7−7 helix-term/src/ui/picker.rs+2−3 helix-term/src/ui/popup.rs+2−3 helix-term/src/ui/prompt.rs+17−17 helix-term/src/ui/text.rs+1−3
helix-term/src/application.rs+11−8
@@ -25,7 +25,14 @@ pub struct Application {
2525 // TODO should be separate to take only part of the config
2626 config: Config,
2727
28+ // Currently never read from. Remove the `allow(dead_code)` when
29+ // that changes.
30+ #[allow(dead_code)]
2831 theme_loader: Arc<theme::Loader>,
32+
33+ // Currently never read from. Remove the `allow(dead_code)` when
34+ // that changes.
35+ #[allow(dead_code)]
2936 syn_loader: Arc<syntax::Loader>,
3037
3138 jobs: Jobs,
@@ -33,7 +40,7 @@ pub struct Application {
3340}
3441
3542impl Application {
36− pub fn new(mut args: Args, mut config: Config) -> Result<Self, Error> {
43+ pub fn new(args: Args, mut config: Config) -> Result<Self, Error> {
3744 use helix_view::editor::Action;
3845 let mut compositor = Compositor::new()?;
3946 let size = compositor.size();
@@ -66,7 +73,7 @@ impl Application {
6673
6774 let mut editor = Editor::new(size, theme_loader.clone(), syn_loader.clone());
6875
69− let mut editor_view = Box::new(ui::EditorView::new(std::mem::take(&mut config.keys)));
76+ let editor_view = Box::new(ui::EditorView::new(std::mem::take(&mut config.keys)));
7077 compositor.push(editor_view);
7178
7279 if !args.files.is_empty() {
@@ -91,7 +98,7 @@ impl Application {
9198
9299 editor.set_theme(theme);
93100
94− let mut app = Self {
101+ let app = Self {
95102 compositor,
96103 editor,
97104
@@ -357,14 +364,10 @@ impl Application {
357364 self.editor.set_status(status);
358365 }
359366 }
360− _ => unreachable!(),
361367 }
362368 }
363369 Call::MethodCall(helix_lsp::jsonrpc::MethodCall {
364− method,
365− params,
366− jsonrpc,
367− id,
370+ method, params, id, ..
368371 }) => {
369372 let call = match MethodCall::parse(&method, params) {
370373 Some(call) => call,
helix-term/src/commands.rs+56−58
@@ -60,7 +60,7 @@ pub struct Context<'a> {
6060
6161impl<'a> Context<'a> {
6262 /// Push a new component onto the compositor.
63− pub fn push_layer(&mut self, mut component: Box<dyn Component>) {
63+ pub fn push_layer(&mut self, component: Box<dyn Component>) {
6464 self.callback = Some(Box::new(|compositor: &mut Compositor| {
6565 compositor.push(component)
6666 }));
@@ -493,7 +493,7 @@ fn extend_next_word_start(cx: &mut Context) {
493493 let (view, doc) = current!(cx.editor);
494494 let text = doc.text().slice(..);
495495
496− let selection = doc.selection(view.id).transform(|mut range| {
496+ let selection = doc.selection(view.id).transform(|range| {
497497 let word = movement::move_next_word_start(text, range, count);
498498 let pos = word.head;
499499 Range::new(range.anchor, pos)
@@ -507,7 +507,7 @@ fn extend_prev_word_start(cx: &mut Context) {
507507 let (view, doc) = current!(cx.editor);
508508 let text = doc.text().slice(..);
509509
510− let selection = doc.selection(view.id).transform(|mut range| {
510+ let selection = doc.selection(view.id).transform(|range| {
511511 let word = movement::move_prev_word_start(text, range, count);
512512 let pos = word.head;
513513 Range::new(range.anchor, pos)
@@ -520,7 +520,7 @@ fn extend_next_word_end(cx: &mut Context) {
520520 let (view, doc) = current!(cx.editor);
521521 let text = doc.text().slice(..);
522522
523− let selection = doc.selection(view.id).transform(|mut range| {
523+ let selection = doc.selection(view.id).transform(|range| {
524524 let word = movement::move_next_word_end(text, range, count);
525525 let pos = word.head;
526526 Range::new(range.anchor, pos)
@@ -571,7 +571,7 @@ where
571571 let (view, doc) = current!(cx.editor);
572572 let text = doc.text().slice(..);
573573
574− let selection = doc.selection(view.id).transform(|mut range| {
574+ let selection = doc.selection(view.id).transform(|range| {
575575 search_fn(text, ch, range.head, count, inclusive).map_or(range, |pos| {
576576 if extend {
577577 Range::new(range.anchor, pos)
@@ -929,7 +929,7 @@ fn search_impl(doc: &mut Document, view: &mut View, contents: &str, regex: &Rege
929929
930930// TODO: use one function for search vs extend
931931fn search(cx: &mut Context) {
932− let (view, doc) = current!(cx.editor);
932+ let (_, doc) = current!(cx.editor);
933933
934934 // TODO: could probably share with select_on_matches?
935935
@@ -937,7 +937,6 @@ fn search(cx: &mut Context) {
937937 // feed chunks into the regex yet
938938 let contents = doc.text().slice(..).to_string();
939939
940− let view_id = view.id;
941940 let prompt = ui::regex_prompt(
942941 cx,
943942 "search:".to_string(),
@@ -989,7 +988,7 @@ fn extend_line(cx: &mut Context) {
989988 let line_start = text.char_to_line(pos.anchor);
990989 let start = text.line_to_char(line_start);
991990 let line_end = text.char_to_line(pos.head);
992− let mut end = line_end_char_index(&text.slice(..), line_end);
991+ let mut end = line_end_char_index(&text.slice(..), line_end + count.saturating_sub(1));
993992
994993 if pos.anchor == start && pos.head == end && line_end < (text.len_lines() - 2) {
995994 end = line_end_char_index(&text.slice(..), line_end + 1);
@@ -1012,7 +1011,6 @@ fn delete_selection_impl(reg: &mut Register, doc: &mut Document, view_id: ViewId
10121011 let transaction =
10131012 Transaction::change_by_selection(doc.text(), doc.selection(view_id), |range| {
10141013 let alltext = doc.text().slice(..);
1015− let line = alltext.char_to_line(range.head);
10161014 let max_to = rope_end_without_line_ending(&alltext);
10171015 let to = std::cmp::min(max_to, range.to() + 1);
10181016 (range.from(), to, None)
@@ -1119,7 +1117,7 @@ mod cmd {
11191117 pub completer: Option<Completer>,
11201118 }
11211119
1122− fn quit(cx: &mut compositor::Context, args: &[&str], event: PromptEvent) {
1120+ fn quit(cx: &mut compositor::Context, _args: &[&str], _event: PromptEvent) {
11231121 // last view and we have unsaved changes
11241122 if cx.editor.tree.views().count() == 1 && buffers_remaining_impl(cx.editor) {
11251123 return;
@@ -1128,12 +1126,12 @@ mod cmd {
11281126 .close(view!(cx.editor).id, /* close_buffer */ false);
11291127 }
11301128
1131− fn force_quit(cx: &mut compositor::Context, args: &[&str], event: PromptEvent) {
1129+ fn force_quit(cx: &mut compositor::Context, _args: &[&str], _event: PromptEvent) {
11321130 cx.editor
11331131 .close(view!(cx.editor).id, /* close_buffer */ false);
11341132 }
11351133
1136− fn open(cx: &mut compositor::Context, args: &[&str], event: PromptEvent) {
1134+ fn open(cx: &mut compositor::Context, args: &[&str], _event: PromptEvent) {
11371135 match args.get(0) {
11381136 Some(path) => {
11391137 // TODO: handle error
@@ -1150,7 +1148,7 @@ mod cmd {
11501148 path: Option<P>,
11511149 ) -> Result<tokio::task::JoinHandle<Result<(), anyhow::Error>>, anyhow::Error> {
11521150 let jobs = &mut cx.jobs;
1153− let (view, doc) = current!(cx.editor);
1151+ let (_, doc) = current!(cx.editor);
11541152
11551153 if let Some(path) = path {
11561154 if let Err(err) = doc.set_path(path.as_ref()) {
@@ -1174,7 +1172,7 @@ mod cmd {
11741172 Ok(tokio::spawn(doc.format_and_save(fmt)))
11751173 }
11761174
1177− fn write(cx: &mut compositor::Context, args: &[&str], event: PromptEvent) {
1175+ fn write(cx: &mut compositor::Context, args: &[&str], _event: PromptEvent) {
11781176 match write_impl(cx, args.first()) {
11791177 Err(e) => cx.editor.set_error(e.to_string()),
11801178 Ok(handle) => {
@@ -1184,11 +1182,11 @@ mod cmd {
11841182 };
11851183 }
11861184
1187− fn new_file(cx: &mut compositor::Context, args: &[&str], event: PromptEvent) {
1185+ fn new_file(cx: &mut compositor::Context, _args: &[&str], _event: PromptEvent) {
11881186 cx.editor.new_file(Action::Replace);
11891187 }
11901188
1191− fn format(cx: &mut compositor::Context, args: &[&str], event: PromptEvent) {
1189+ fn format(cx: &mut compositor::Context, _args: &[&str], _event: PromptEvent) {
11921190 let (_, doc) = current!(cx.editor);
11931191
11941192 if let Some(format) = doc.format() {
@@ -1198,7 +1196,7 @@ mod cmd {
11981196 }
11991197 }
12001198
1201− fn set_indent_style(cx: &mut compositor::Context, args: &[&str], event: PromptEvent) {
1199+ fn set_indent_style(cx: &mut compositor::Context, args: &[&str], _event: PromptEvent) {
12021200 use IndentStyle::*;
12031201
12041202 // If no argument, report current indent style.
@@ -1236,7 +1234,7 @@ mod cmd {
12361234 }
12371235
12381236 /// Sets or reports the current document's line ending setting.
1239− fn set_line_ending(cx: &mut compositor::Context, args: &[&str], event: PromptEvent) {
1237+ fn set_line_ending(cx: &mut compositor::Context, args: &[&str], _event: PromptEvent) {
12401238 use LineEnding::*;
12411239
12421240 // If no argument, report current line ending setting.
@@ -1275,7 +1273,7 @@ mod cmd {
12751273 }
12761274 }
12771275
1278− fn earlier(cx: &mut compositor::Context, args: &[&str], event: PromptEvent) {
1276+ fn earlier(cx: &mut compositor::Context, args: &[&str], _event: PromptEvent) {
12791277 let uk = match args.join(" ").parse::<helix_core::history::UndoKind>() {
12801278 Ok(uk) => uk,
12811279 Err(msg) => {
@@ -1287,7 +1285,7 @@ mod cmd {
12871285 doc.earlier(view.id, uk)
12881286 }
12891287
1290− fn later(cx: &mut compositor::Context, args: &[&str], event: PromptEvent) {
1288+ fn later(cx: &mut compositor::Context, args: &[&str], _event: PromptEvent) {
12911289 let uk = match args.join(" ").parse::<helix_core::history::UndoKind>() {
12921290 Ok(uk) => uk,
12931291 Err(msg) => {
@@ -1315,7 +1313,6 @@ mod cmd {
13151313 }
13161314
13171315 fn force_write_quit(cx: &mut compositor::Context, args: &[&str], event: PromptEvent) {
1318− let (view, doc) = current!(cx.editor);
13191316 match write_impl(cx, args.first()) {
13201317 Ok(handle) => {
13211318 if let Err(e) = helix_lsp::block_on(handle) {
@@ -1357,15 +1354,15 @@ mod cmd {
13571354
13581355 fn write_all_impl(
13591356 editor: &mut Editor,
1360− args: &[&str],
1361− event: PromptEvent,
1357+ _args: &[&str],
1358+ _event: PromptEvent,
13621359 quit: bool,
13631360 force: bool,
13641361 ) {
13651362 let mut errors = String::new();
13661363
13671364 // save all documents
1368− for (id, mut doc) in &mut editor.documents {
1365+ for (_, doc) in &mut editor.documents {
13691366 if doc.path().is_none() {
13701367 errors.push_str("cannot write a buffer without a filename\n");
13711368 continue;
@@ -1399,7 +1396,7 @@ mod cmd {
13991396 write_all_impl(&mut cx.editor, args, event, true, true)
14001397 }
14011398
1402− fn quit_all_impl(editor: &mut Editor, args: &[&str], event: PromptEvent, force: bool) {
1399+ fn quit_all_impl(editor: &mut Editor, _args: &[&str], _event: PromptEvent, force: bool) {
14031400 if !force && buffers_remaining_impl(editor) {
14041401 return;
14051402 }
@@ -1419,7 +1416,7 @@ mod cmd {
14191416 quit_all_impl(&mut cx.editor, args, event, true)
14201417 }
14211418
1422− fn theme(cx: &mut compositor::Context, args: &[&str], event: PromptEvent) {
1419+ fn theme(cx: &mut compositor::Context, args: &[&str], _event: PromptEvent) {
14231420 let theme = if let Some(theme) = args.first() {
14241421 theme
14251422 } else {
@@ -1430,11 +1427,15 @@ mod cmd {
14301427 cx.editor.set_theme_from_name(theme);
14311428 }
14321429
1433− fn yank_main_selection_to_clipboard(cx: &mut compositor::Context, _: &[&str], _: PromptEvent) {
1430+ fn yank_main_selection_to_clipboard(
1431+ cx: &mut compositor::Context,
1432+ _args: &[&str],
1433+ _event: PromptEvent,
1434+ ) {
14341435 yank_main_selection_to_clipboard_impl(&mut cx.editor);
14351436 }
14361437
1437− fn yank_joined_to_clipboard(cx: &mut compositor::Context, args: &[&str], _: PromptEvent) {
1438+ fn yank_joined_to_clipboard(cx: &mut compositor::Context, args: &[&str], _event: PromptEvent) {
14381439 let (_, doc) = current!(cx.editor);
14391440 let separator = args
14401441 .first()
@@ -1443,15 +1444,19 @@ mod cmd {
14431444 yank_joined_to_clipboard_impl(&mut cx.editor, separator);
14441445 }
14451446
1446− fn paste_clipboard_after(cx: &mut compositor::Context, _: &[&str], _: PromptEvent) {
1447+ fn paste_clipboard_after(cx: &mut compositor::Context, _args: &[&str], _event: PromptEvent) {
14471448 paste_clipboard_impl(&mut cx.editor, Paste::After);
14481449 }
14491450
1450− fn paste_clipboard_before(cx: &mut compositor::Context, _: &[&str], _: PromptEvent) {
1451+ fn paste_clipboard_before(cx: &mut compositor::Context, _args: &[&str], _event: PromptEvent) {
14511452 paste_clipboard_impl(&mut cx.editor, Paste::After);
14521453 }
14531454
1454− fn replace_selections_with_clipboard(cx: &mut compositor::Context, _: &[&str], _: PromptEvent) {
1455+ fn replace_selections_with_clipboard(
1456+ cx: &mut compositor::Context,
1457+ _args: &[&str],
1458+ _event: PromptEvent,
1459+ ) {
14551460 let (view, doc) = current!(cx.editor);
14561461
14571462 match cx.editor.clipboard_provider.get_contents() {
@@ -1470,12 +1475,12 @@ mod cmd {
14701475 }
14711476 }
14721477
1473− fn show_clipboard_provider(cx: &mut compositor::Context, _: &[&str], _: PromptEvent) {
1478+ fn show_clipboard_provider(cx: &mut compositor::Context, _args: &[&str], _event: PromptEvent) {
14741479 cx.editor
14751480 .set_status(cx.editor.clipboard_provider.name().into());
14761481 }
14771482
1478− fn change_current_directory(cx: &mut compositor::Context, args: &[&str], _: PromptEvent) {
1483+ fn change_current_directory(cx: &mut compositor::Context, args: &[&str], _event: PromptEvent) {
14791484 let dir = match args.first() {
14801485 Some(dir) => dir,
14811486 None => {
@@ -1503,7 +1508,7 @@ mod cmd {
15031508 }
15041509 }
15051510
1506− fn show_current_directory(cx: &mut compositor::Context, args: &[&str], _: PromptEvent) {
1511+ fn show_current_directory(cx: &mut compositor::Context, _args: &[&str], _event: PromptEvent) {
15071512 match std::env::current_dir() {
15081513 Ok(cwd) => cx
15091514 .editor
@@ -1836,7 +1841,7 @@ fn symbol_picker(cx: &mut Context) {
18361841 nested_to_flat(list, file, child);
18371842 }
18381843 }
1839− let (view, doc) = current!(cx.editor);
1844+ let (_, doc) = current!(cx.editor);
18401845
18411846 let language_server = match doc.language_server() {
18421847 Some(language_server) => language_server,
@@ -1927,7 +1932,7 @@ async fn make_format_callback(
19271932 format: impl Future<Output = helix_lsp::util::LspFormatting> + Send + 'static,
19281933) -> anyhow::Result<job::Callback> {
19291934 let format = format.await;
1930− let call: job::Callback = Box::new(move |editor: &mut Editor, compositor: &mut Compositor| {
1935+ let call: job::Callback = Box::new(move |editor: &mut Editor, _compositor: &mut Compositor| {
19311936 let view_id = view!(editor).id;
19321937 if let Some(doc) = editor.document_mut(doc_id) {
19331938 if doc.version() == doc_version {
@@ -2101,9 +2106,6 @@ fn goto_mode(cx: &mut Context) {
21012106 (_, 't') | (_, 'm') | (_, 'b') => {
21022107 let (view, doc) = current!(cx.editor);
21032108
2104− let pos = doc.selection(view.id).cursor();
2105− let line = doc.text().char_to_line(pos);
2106−
21072109 let scrolloff = PADDING.min(view.area.height as usize / 2); // TODO: user pref
21082110
21092111 let last_line = view.last_line(doc);
@@ -2152,7 +2154,7 @@ fn goto_impl(
21522154 .uri
21532155 .to_file_path()
21542156 .expect("unable to convert URI to filepath");
2155− let id = editor.open(path, action).expect("editor.open failed");
2157+ let _id = editor.open(path, action).expect("editor.open failed");
21562158 let (view, doc) = current!(editor);
21572159 let definition_pos = location.range.start;
21582160 // TODO: convert inside server
@@ -2174,7 +2176,7 @@ fn goto_impl(
21742176 editor.set_error("No definition found.".to_string());
21752177 }
21762178 _locations => {
2177− let mut picker = ui::Picker::new(
2179+ let picker = ui::Picker::new(
21782180 locations,
21792181 |location| {
21802182 let file = location.uri.as_str();
@@ -2341,9 +2343,8 @@ fn goto_pos(editor: &mut Editor, pos: usize) {
23412343
23422344fn goto_first_diag(cx: &mut Context) {
23432345 let editor = &mut cx.editor;
2344− let (view, doc) = current!(editor);
2346+ let (_, doc) = current!(editor);
23452347
2346− let cursor_pos = doc.selection(view.id).cursor();
23472348 let diag = if let Some(diag) = doc.diagnostics().first() {
23482349 diag.range.start
23492350 } else {
@@ -2355,9 +2356,8 @@ fn goto_first_diag(cx: &mut Context) {
23552356
23562357fn goto_last_diag(cx: &mut Context) {
23572358 let editor = &mut cx.editor;
2358− let (view, doc) = current!(editor);
2359+ let (_, doc) = current!(editor);
23592360
2360− let cursor_pos = doc.selection(view.id).cursor();
23612361 let diag = if let Some(diag) = doc.diagnostics().last() {
23622362 diag.range.start
23632363 } else {
@@ -2429,8 +2429,8 @@ fn signature_help(cx: &mut Context) {
24292429
24302430 cx.callback(
24312431 future,
2432− move |editor: &mut Editor,
2433− compositor: &mut Compositor,
2432+ move |_editor: &mut Editor,
2433+ _compositor: &mut Compositor,
24342434 response: Option<lsp::SignatureHelp>| {
24352435 if let Some(signature_help) = response {
24362436 log::info!("{:?}", signature_help);
@@ -3002,8 +3002,10 @@ fn format_selections(cx: &mut Context) {
30023002 .map(|range| range_to_lsp_range(doc.text(), *range, language_server.offset_encoding()))
30033003 .collect();
30043004
3005− for range in ranges {
3006− let language_server = match doc.language_server() {
3005+ // TODO: all of the TODO's and commented code inside the loop,
3006+ // to make this actually work.
3007+ for _range in ranges {
3008+ let _language_server = match doc.language_server() {
30073009 Some(language_server) => language_server,
30083010 None => return,
30093011 };
@@ -3051,7 +3053,7 @@ fn join_selections(cx: &mut Context) {
30513053 changes.reserve(lines.len());
30523054
30533055 for line in lines {
3054− let mut start = line_end_char_index(&slice, line);
3056+ let start = line_end_char_index(&slice, line);
30553057 let mut end = text.line_to_char(line + 1);
30563058 end = skip_while(slice, end, |ch| matches!(ch, ' ' | '\t')).unwrap_or(end);
30573059
@@ -3227,7 +3229,7 @@ fn hover(cx: &mut Context) {
32273229 // skip if contents empty
32283230
32293231 let contents = ui::Markdown::new(contents, editor.syn_loader.clone());
3230− let mut popup = Popup::new(contents);
3232+ let popup = Popup::new(contents);
32313233 compositor.push(Box::new(popup));
32323234 }
32333235 },
@@ -3271,7 +3273,7 @@ fn match_brackets(cx: &mut Context) {
32713273
32723274fn jump_forward(cx: &mut Context) {
32733275 let count = cx.count();
3274− let (view, doc) = current!(cx.editor);
3276+ let (view, _doc) = current!(cx.editor);
32753277
32763278 if let Some((id, selection)) = view.jumps.forward(count) {
32773279 view.doc = *id;
@@ -3480,10 +3482,7 @@ fn match_mode(cx: &mut Context) {
34803482 'm' => match_brackets(cx),
34813483 's' => surround_add(cx),
34823484 'r' => surround_replace(cx),
3483− 'd' => {
3484− surround_delete(cx);
3485− let (view, doc) = current!(cx.editor);
3486− }
3485+ 'd' => surround_delete(cx),
34873486 _ => (),
34883487 }
34893488 }
@@ -3505,9 +3504,8 @@ fn surround_add(cx: &mut Context) {
35053504 let (open, close) = surround::get_pair(ch);
35063505
35073506 let mut changes = Vec::new();
3508− for (i, range) in selection.iter().enumerate() {
3507+ for range in selection.iter() {
35093508 let from = range.from();
3510− let line = text.char_to_line(range.to());
35113509 let max_to = rope_end_without_line_ending(&text);
35123510 let to = std::cmp::min(range.to() + 1, max_to);
35133511
helix-term/src/compositor.rs+5−6
@@ -35,7 +35,7 @@ pub struct Context<'a> {
3535
3636pub trait Component: Any + AnyComponent {
3737 /// Process input events, return true if handled.
38− fn handle_event(&mut self, event: Event, ctx: &mut Context) -> EventResult {
38+ fn handle_event(&mut self, _event: Event, _ctx: &mut Context) -> EventResult {
3939 EventResult::Ignored
4040 }
4141 // , args: ()
@@ -49,13 +49,13 @@ pub trait Component: Any + AnyComponent {
4949 fn render(&self, area: Rect, frame: &mut Surface, ctx: &mut Context);
5050
5151 /// Get cursor position and cursor kind.
52− fn cursor(&self, area: Rect, ctx: &Editor) -> (Option<Position>, CursorKind) {
52+ fn cursor(&self, _area: Rect, _ctx: &Editor) -> (Option<Position>, CursorKind) {
5353 (None, CursorKind::Hidden)
5454 }
5555
5656 /// May be used by the parent component to compute the child area.
5757 /// viewport is the maximum allowed area, and the child should stay within those bounds.
58− fn required_size(&mut self, viewport: (u16, u16)) -> Option<(u16, u16)> {
58+ fn required_size(&mut self, _viewport: (u16, u16)) -> Option<(u16, u16)> {
5959 // TODO: for scrolling, the scroll wrapper should place a size + offset on the Context
6060 // that way render can use it
6161 None
@@ -79,7 +79,7 @@ pub struct Compositor {
7979impl Compositor {
8080 pub fn new() -> Result<Self, Error> {
8181 let backend = CrosstermBackend::new(stdout());
82− let mut terminal = Terminal::new(backend)?;
82+ let terminal = Terminal::new(backend)?;
8383 Ok(Self {
8484 layers: Vec::new(),
8585 terminal,
@@ -124,8 +124,7 @@ impl Compositor {
124124 }
125125
126126 pub fn render(&mut self, cx: &mut Context) {
127− let area = self
128− .terminal
127+ self.terminal
129128 .autoresize()
130129 .expect("Unable to determine terminal size");
131130
helix-term/src/ui/completion.rs+1−1
@@ -76,7 +76,7 @@ impl Completion {
7676 trigger_offset: usize,
7777 ) -> Self {
7878 // let items: Vec<CompletionItem> = Vec::new();
79− let mut menu = Menu::new(items, move |editor: &mut Editor, item, event| {
79+ let menu = Menu::new(items, move |editor: &mut Editor, item, event| {
8080 match event {
8181 PromptEvent::Abort => {}
8282 PromptEvent::Validate => {
helix-term/src/ui/editor.rs+4−5
@@ -392,7 +392,7 @@ impl EditorView {
392392 viewport: Rect,
393393 surface: &mut Surface,
394394 theme: &Theme,
395− is_focused: bool,
395+ _is_focused: bool,
396396 ) {
397397 use helix_core::diagnostic::Severity;
398398 use tui::{
@@ -402,7 +402,6 @@ impl EditorView {
402402 };
403403
404404 let cursor = doc.selection(view.id).cursor();
405− let line = doc.text().char_to_line(cursor);
406405
407406 let diagnostics = doc.diagnostics().iter().filter(|diagnostic| {
408407 diagnostic.range.start <= cursor && diagnostic.range.end >= cursor
@@ -608,7 +607,7 @@ impl Component for EditorView {
608607 // clear status
609608 cx.editor.status_msg = None;
610609
611− let (view, doc) = current!(cx.editor);
610+ let (_, doc) = current!(cx.editor);
612611 let mode = doc.mode();
613612
614613 let mut cxt = commands::Context {
@@ -705,7 +704,7 @@ impl Component for EditorView {
705704 }
706705 }
707706
708− fn render(&self, mut area: Rect, surface: &mut Surface, cx: &mut Context) {
707+ fn render(&self, area: Rect, surface: &mut Surface, cx: &mut Context) {
709708 // clear with background color
710709 surface.set_style(area, cx.editor.theme.get("ui.background"));
711710
@@ -741,7 +740,7 @@ impl Component for EditorView {
741740 }
742741 }
743742
744− fn cursor(&self, area: Rect, editor: &Editor) -> (Option<Position>, CursorKind) {
743+ fn cursor(&self, _area: Rect, editor: &Editor) -> (Option<Position>, CursorKind) {
745744 // match view.doc.mode() {
746745 // Mode::Insert => write!(stdout, "\x1B[6 q"),
747746 // mode => write!(stdout, "\x1B[2 q"),
helix-term/src/ui/markdown.rs+5−5
@@ -40,8 +40,8 @@ fn parse<'a>(
4040 theme: Option<&Theme>,
4141 loader: &syntax::Loader,
4242) -> tui::text::Text<'a> {
43− // also 2021-03-04T16:33:58.553 helix_lsp::transport [INFO] <- {"contents":{"kind":"markdown","value":"\n```rust\ncore::num\n```\n\n```rust\npub const fn saturating_sub(self, rhs:Self) ->Self\n```\n\n---\n\n```rust\n```"},"range":{"end":{"character":61,"line":101},"start":{"character":47,"line":101}}}
44− let text = "\n```rust\ncore::iter::traits::iterator::Iterator\n```\n\n```rust\nfn collect<B: FromIterator<Self::Item>>(self) -> B\nwhere\n Self: Sized,\n```\n\n---\n\nTransforms an iterator into a collection.\n\n`collect()` can take anything iterable, and turn it into a relevant\ncollection. This is one of the more powerful methods in the standard\nlibrary, used in a variety of contexts.\n\nThe most basic pattern in which `collect()` is used is to turn one\ncollection into another. You take a collection, call [`iter`](https://doc.rust-lang.org/nightly/core/iter/traits/iterator/trait.Iterator.html) on it,\ndo a bunch of transformations, and then `collect()` at the end.\n\n`collect()` can also create instances of types that are not typical\ncollections. For example, a [`String`](https://doc.rust-lang.org/nightly/core/iter/std/string/struct.String.html) can be built from [`char`](type@char)s,\nand an iterator of [`Result<T, E>`](https://doc.rust-lang.org/nightly/core/result/enum.Result.html) items can be collected\ninto `Result<Collection<T>, E>`. See the examples below for more.\n\nBecause `collect()` is so general, it can cause problems with type\ninference. As such, `collect()` is one of the few times you'll see\nthe syntax affectionately known as the 'turbofish': `::<>`. This\nhelps the inference algorithm understand specifically which collection\nyou're trying to collect into.\n\n# Examples\n\nBasic usage:\n\n```rust\nlet a = [1, 2, 3];\n\nlet doubled: Vec<i32> = a.iter()\n .map(|&x| x * 2)\n .collect();\n\nassert_eq!(vec![2, 4, 6], doubled);\n```\n\nNote that we needed the `: Vec<i32>` on the left-hand side. This is because\nwe could collect into, for example, a [`VecDeque<T>`](https://doc.rust-lang.org/nightly/core/iter/std/collections/struct.VecDeque.html) instead:\n\n```rust\nuse std::collections::VecDeque;\n\nlet a = [1, 2, 3];\n\nlet doubled: VecDeque<i32> = a.iter().map(|&x| x * 2).collect();\n\nassert_eq!(2, doubled[0]);\nassert_eq!(4, doubled[1]);\nassert_eq!(6, doubled[2]);\n```\n\nUsing the 'turbofish' instead of annotating `doubled`:\n\n```rust\nlet a = [1, 2, 3];\n\nlet doubled = a.iter().map(|x| x * 2).collect::<Vec<i32>>();\n\nassert_eq!(vec![2, 4, 6], doubled);\n```\n\nBecause `collect()` only cares about what you're collecting into, you can\nstill use a partial type hint, `_`, with the turbofish:\n\n```rust\nlet a = [1, 2, 3];\n\nlet doubled = a.iter().map(|x| x * 2).collect::<Vec<_>>();\n\nassert_eq!(vec![2, 4, 6], doubled);\n```\n\nUsing `collect()` to make a [`String`](https://doc.rust-lang.org/nightly/core/iter/std/string/struct.String.html):\n\n```rust\nlet chars = ['g', 'd', 'k', 'k', 'n'];\n\nlet hello: String = chars.iter()\n .map(|&x| x as u8)\n .map(|x| (x + 1) as char)\n .collect();\n\nassert_eq!(\"hello\", hello);\n```\n\nIf you have a list of [`Result<T, E>`](https://doc.rust-lang.org/nightly/core/result/enum.Result.html)s, you can use `collect()` to\nsee if any of them failed:\n\n```rust\nlet results = [Ok(1), Err(\"nope\"), Ok(3), Err(\"bad\")];\n\nlet result: Result<Vec<_>, &str> = results.iter().cloned().collect();\n\n// gives us the first error\nassert_eq!(Err(\"nope\"), result);\n\nlet results = [Ok(1), Ok(3)];\n\nlet result: Result<Vec<_>, &str> = results.iter().cloned().collect();\n\n// gives us the list of answers\nassert_eq!(Ok(vec![1, 3]), result);\n```";
43+ // // also 2021-03-04T16:33:58.553 helix_lsp::transport [INFO] <- {"contents":{"kind":"markdown","value":"\n```rust\ncore::num\n```\n\n```rust\npub const fn saturating_sub(self, rhs:Self) ->Self\n```\n\n---\n\n```rust\n```"},"range":{"end":{"character":61,"line":101},"start":{"character":47,"line":101}}}
44+ // let text = "\n```rust\ncore::iter::traits::iterator::Iterator\n```\n\n```rust\nfn collect<B: FromIterator<Self::Item>>(self) -> B\nwhere\n Self: Sized,\n```\n\n---\n\nTransforms an iterator into a collection.\n\n`collect()` can take anything iterable, and turn it into a relevant\ncollection. This is one of the more powerful methods in the standard\nlibrary, used in a variety of contexts.\n\nThe most basic pattern in which `collect()` is used is to turn one\ncollection into another. You take a collection, call [`iter`](https://doc.rust-lang.org/nightly/core/iter/traits/iterator/trait.Iterator.html) on it,\ndo a bunch of transformations, and then `collect()` at the end.\n\n`collect()` can also create instances of types that are not typical\ncollections. For example, a [`String`](https://doc.rust-lang.org/nightly/core/iter/std/string/struct.String.html) can be built from [`char`](type@char)s,\nand an iterator of [`Result<T, E>`](https://doc.rust-lang.org/nightly/core/result/enum.Result.html) items can be collected\ninto `Result<Collection<T>, E>`. See the examples below for more.\n\nBecause `collect()` is so general, it can cause problems with type\ninference. As such, `collect()` is one of the few times you'll see\nthe syntax affectionately known as the 'turbofish': `::<>`. This\nhelps the inference algorithm understand specifically which collection\nyou're trying to collect into.\n\n# Examples\n\nBasic usage:\n\n```rust\nlet a = [1, 2, 3];\n\nlet doubled: Vec<i32> = a.iter()\n .map(|&x| x * 2)\n .collect();\n\nassert_eq!(vec![2, 4, 6], doubled);\n```\n\nNote that we needed the `: Vec<i32>` on the left-hand side. This is because\nwe could collect into, for example, a [`VecDeque<T>`](https://doc.rust-lang.org/nightly/core/iter/std/collections/struct.VecDeque.html) instead:\n\n```rust\nuse std::collections::VecDeque;\n\nlet a = [1, 2, 3];\n\nlet doubled: VecDeque<i32> = a.iter().map(|&x| x * 2).collect();\n\nassert_eq!(2, doubled[0]);\nassert_eq!(4, doubled[1]);\nassert_eq!(6, doubled[2]);\n```\n\nUsing the 'turbofish' instead of annotating `doubled`:\n\n```rust\nlet a = [1, 2, 3];\n\nlet doubled = a.iter().map(|x| x * 2).collect::<Vec<i32>>();\n\nassert_eq!(vec![2, 4, 6], doubled);\n```\n\nBecause `collect()` only cares about what you're collecting into, you can\nstill use a partial type hint, `_`, with the turbofish:\n\n```rust\nlet a = [1, 2, 3];\n\nlet doubled = a.iter().map(|x| x * 2).collect::<Vec<_>>();\n\nassert_eq!(vec![2, 4, 6], doubled);\n```\n\nUsing `collect()` to make a [`String`](https://doc.rust-lang.org/nightly/core/iter/std/string/struct.String.html):\n\n```rust\nlet chars = ['g', 'd', 'k', 'k', 'n'];\n\nlet hello: String = chars.iter()\n .map(|&x| x as u8)\n .map(|x| (x + 1) as char)\n .collect();\n\nassert_eq!(\"hello\", hello);\n```\n\nIf you have a list of [`Result<T, E>`](https://doc.rust-lang.org/nightly/core/result/enum.Result.html)s, you can use `collect()` to\nsee if any of them failed:\n\n```rust\nlet results = [Ok(1), Err(\"nope\"), Ok(3), Err(\"bad\")];\n\nlet result: Result<Vec<_>, &str> = results.iter().cloned().collect();\n\n// gives us the first error\nassert_eq!(Err(\"nope\"), result);\n\nlet results = [Ok(1), Ok(3)];\n\nlet result: Result<Vec<_>, &str> = results.iter().cloned().collect();\n\n// gives us the list of answers\nassert_eq!(Ok(vec![1, 3]), result);\n```";
4545
4646 let mut options = Options::empty();
4747 options.insert(Options::ENABLE_STRIKETHROUGH);
@@ -92,7 +92,7 @@ fn parse<'a>(
9292 .and_then(|config| config.highlight_config(theme.scopes()))
9393 .map(|config| Syntax::new(&rope, config));
9494
95− if let Some(mut syntax) = syntax {
95+ if let Some(syntax) = syntax {
9696 // if we have a syntax available, highlight_iter and generate spans
9797 let mut highlights = Vec::new();
9898
@@ -142,13 +142,13 @@ fn parse<'a>(
142142 }
143143 } else {
144144 for line in text.lines() {
145− let mut span = Span::styled(line.to_string(), code_style);
145+ let span = Span::styled(line.to_string(), code_style);
146146 lines.push(Spans::from(span));
147147 }
148148 }
149149 } else {
150150 for line in text.lines() {
151− let mut span = Span::styled(line.to_string(), code_style);
151+ let span = Span::styled(line.to_string(), code_style);
152152 lines.push(Spans::from(span));
153153 }
154154 }
helix-term/src/ui/menu.rs+1−2
@@ -58,7 +58,6 @@ impl<T: Item> Menu<T> {
5858 pub fn score(&mut self, pattern: &str) {
5959 // need to borrow via pattern match otherwise it complains about simultaneous borrow
6060 let Self {
61− ref mut options,
6261 ref mut matcher,
6362 ref mut matches,
6463 ..
@@ -291,7 +290,7 @@ impl<T: Item + 'static> Component for Menu<T> {
291290 // )
292291 // }
293292
294− for (i, option) in (scroll..(scroll + win_height).min(len)).enumerate() {
293+ for (i, _) in (scroll..(scroll + win_height).min(len)).enumerate() {
295294 let is_marked = i >= scroll_line && i < scroll_line + scroll_height;
296295
297296 if is_marked {
helix-term/src/ui/mod.rs+7−7
@@ -35,7 +35,7 @@ pub fn regex_prompt(
3535
3636 Prompt::new(
3737 prompt,
38− |input: &str| Vec::new(), // this is fine because Vec::new() doesn't allocate
38+ |_input: &str| Vec::new(), // this is fine because Vec::new() doesn't allocate
3939 move |cx: &mut crate::compositor::Context, input: &str, event: PromptEvent| {
4040 match event {
4141 PromptEvent::Abort => {
@@ -118,7 +118,7 @@ pub fn file_picker(root: PathBuf) -> Picker<PathBuf> {
118118 .into()
119119 },
120120 move |editor: &mut Editor, path: &PathBuf, action| {
121− let document_id = editor
121+ editor
122122 .open(path.into(), action)
123123 .expect("editor.open failed");
124124 },
@@ -151,7 +151,7 @@ pub mod completers {
151151
152152 let mut matches: Vec<_> = names
153153 .into_iter()
154− .filter_map(|(range, name)| {
154+ .filter_map(|(_range, name)| {
155155 matcher.fuzzy_match(&name, input).map(|score| (name, score))
156156 })
157157 .collect();
@@ -226,7 +226,7 @@ pub mod completers {
226226 (path, file_name)
227227 };
228228
229− let end = (input.len()..);
229+ let end = input.len()..;
230230
231231 let mut files: Vec<_> = WalkBuilder::new(dir.clone())
232232 .max_depth(Some(1))
@@ -239,7 +239,7 @@ pub mod completers {
239239 return None;
240240 }
241241
242− let is_dir = entry.file_type().map_or(false, |entry| entry.is_dir());
242+ //let is_dir = entry.file_type().map_or(false, |entry| entry.is_dir());
243243
244244 let path = entry.path();
245245 let mut path = if is_tilde {
@@ -271,14 +271,14 @@ pub mod completers {
271271 // inefficient, but we need to calculate the scores, filter out None, then sort.
272272 let mut matches: Vec<_> = files
273273 .into_iter()
274− .filter_map(|(range, file)| {
274+ .filter_map(|(_range, file)| {
275275 matcher
276276 .fuzzy_match(&file, &file_name)
277277 .map(|score| (file, score))
278278 })
279279 .collect();
280280
281− let range = ((input.len().saturating_sub(file_name.len()))..);
281+ let range = (input.len().saturating_sub(file_name.len()))..;
282282
283283 matches.sort_unstable_by_key(|(_file, score)| Reverse(*score));
284284 files = matches
helix-term/src/ui/picker.rs+2−3
@@ -43,8 +43,8 @@ impl<T> Picker<T> {
4343 ) -> Self {
4444 let prompt = Prompt::new(
4545 "".to_string(),
46− |pattern: &str| Vec::new(),
47− |editor: &mut Context, pattern: &str, event: PromptEvent| {
46+ |_pattern: &str| Vec::new(),
47+ |_editor: &mut Context, _pattern: &str, _event: PromptEvent| {
4848 //
4949 },
5050 );
@@ -69,7 +69,6 @@ impl<T> Picker<T> {
6969 pub fn score(&mut self) {
7070 // need to borrow via pattern match otherwise it complains about simultaneous borrow
7171 let Self {
72− ref mut options,
7372 ref mut matcher,
7473 ref mut matches,
7574 ref filters,
helix-term/src/ui/popup.rs+2−3
@@ -52,7 +52,7 @@ impl<T: Component> Component for Popup<T> {
5252 fn handle_event(&mut self, event: Event, cx: &mut Context) -> EventResult {
5353 let key = match event {
5454 Event::Key(event) => event,
55− Event::Resize(width, height) => {
55+ Event::Resize(_, _) => {
5656 // TODO: calculate inner area, call component's handle_event with that area
5757 return EventResult::Ignored;
5858 }
@@ -94,7 +94,7 @@ impl<T: Component> Component for Popup<T> {
9494 // tab/enter/ctrl-k or whatever will confirm the selection/ ctrl-n/ctrl-p for scroll.
9595 }
9696
97− fn required_size(&mut self, viewport: (u16, u16)) -> Option<(u16, u16)> {
97+ fn required_size(&mut self, _viewport: (u16, u16)) -> Option<(u16, u16)> {
9898 let (width, height) = self
9999 .contents
100100 .required_size((120, 26)) // max width, max height
@@ -130,7 +130,6 @@ impl<T: Component> Component for Popup<T> {
130130 rel_y += 1 // position below point
131131 }
132132
133− let area = Rect::new(rel_x, rel_y, width, height);
134133 // clip to viewport
135134 let area = viewport.intersection(Rect::new(rel_x, rel_y, width, height));
136135
helix-term/src/ui/prompt.rs+17−17
@@ -396,6 +396,22 @@ impl Component for Prompt {
396396 (self.callback_fn)(cx, &self.line, PromptEvent::Abort);
397397 return close_fn;
398398 }
399+ KeyEvent {
400+ code: KeyCode::Left,
401+ modifiers: KeyModifiers::ALT,
402+ }
403+ | KeyEvent {
404+ code: KeyCode::Char('b'),
405+ modifiers: KeyModifiers::ALT,
406+ } => self.move_cursor(Movement::BackwardWord(1)),
407+ KeyEvent {
408+ code: KeyCode::Right,
409+ modifiers: KeyModifiers::ALT,
410+ }
411+ | KeyEvent {
412+ code: KeyCode::Char('f'),
413+ modifiers: KeyModifiers::ALT,
414+ } => self.move_cursor(Movement::ForwardWord(1)),
399415 KeyEvent {
400416 code: KeyCode::Char('f'),
401417 modifiers: KeyModifiers::CONTROL,
@@ -428,22 +444,6 @@ impl Component for Prompt {
428444 code: KeyCode::Char('a'),
429445 modifiers: KeyModifiers::CONTROL,
430446 } => self.move_start(),
431− KeyEvent {
432− code: KeyCode::Left,
433− modifiers: KeyModifiers::ALT,
434− }
435− | KeyEvent {
436− code: KeyCode::Char('b'),
437− modifiers: KeyModifiers::ALT,
438− } => self.move_cursor(Movement::BackwardWord(1)),
439− KeyEvent {
440− code: KeyCode::Right,
441− modifiers: KeyModifiers::ALT,
442− }
443− | KeyEvent {
444− code: KeyCode::Char('f'),
445− modifiers: KeyModifiers::ALT,
446− } => self.move_cursor(Movement::ForwardWord(1)),
447447 KeyEvent {
448448 code: KeyCode::Char('w'),
449449 modifiers: KeyModifiers::CONTROL,
@@ -492,7 +492,7 @@ impl Component for Prompt {
492492 self.render_prompt(area, surface, cx)
493493 }
494494
495− fn cursor(&self, area: Rect, editor: &Editor) -> (Option<Position>, CursorKind) {
495+ fn cursor(&self, area: Rect, _editor: &Editor) -> (Option<Position>, CursorKind) {
496496 let line = area.height as usize - 1;
497497 (
498498 Some(Position::new(
helix-term/src/ui/text.rs+1−3
@@ -13,12 +13,10 @@ impl Text {
1313 }
1414}
1515impl Component for Text {
16− fn render(&self, area: Rect, surface: &mut Surface, cx: &mut Context) {
16+ fn render(&self, area: Rect, surface: &mut Surface, _cx: &mut Context) {
1717 use tui::widgets::{Paragraph, Widget, Wrap};
1818 let contents = tui::text::Text::from(self.contents.clone());
1919
20− let style = cx.editor.theme.get("ui.text");
21−
2220 let par = Paragraph::new(contents).wrap(Wrap { trim: false });
2321 // .scroll(x, y) offsets
2422