on master help sign in
Fix unused variable, parameter, and `mut` warnings in helix-term.
efa3389Nathan Vegdahl
helix-term/src/application.rs+11−8
@@ -25,7 +25,14 @@ pub struct Application {
25 // TODO should be separate to take only part of the config
25 // TODO should be separate to take only part of the config
26 config: Config,
26 config: Config,
27
27
28+ // Currently never read from. Remove the `allow(dead_code)` when
29+ // that changes.
30+ #[allow(dead_code)]
28 theme_loader: Arc<theme::Loader>,
31 theme_loader: Arc<theme::Loader>,
32+
33+ // Currently never read from. Remove the `allow(dead_code)` when
34+ // that changes.
35+ #[allow(dead_code)]
29 syn_loader: Arc<syntax::Loader>,
36 syn_loader: Arc<syntax::Loader>,
30
37
31 jobs: Jobs,
38 jobs: Jobs,
@@ -33,7 +40,7 @@ pub struct Application {
33}
40}
34
41
35impl Application {
42impl 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> {
37 use helix_view::editor::Action;
44 use helix_view::editor::Action;
38 let mut compositor = Compositor::new()?;
45 let mut compositor = Compositor::new()?;
39 let size = compositor.size();
46 let size = compositor.size();
@@ -66,7 +73,7 @@ impl Application {
66
73
67 let mut editor = Editor::new(size, theme_loader.clone(), syn_loader.clone());
74 let mut editor = Editor::new(size, theme_loader.clone(), syn_loader.clone());
68
75
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)));
70 compositor.push(editor_view);
77 compositor.push(editor_view);
71
78
72 if !args.files.is_empty() {
79 if !args.files.is_empty() {
@@ -91,7 +98,7 @@ impl Application {
91
98
92 editor.set_theme(theme);
99 editor.set_theme(theme);
93
100
94− let mut app = Self {
101+ let app = Self {
95 compositor,
102 compositor,
96 editor,
103 editor,
97
104
@@ -357,14 +364,10 @@ impl Application {
357 self.editor.set_status(status);
364 self.editor.set_status(status);
358 }
365 }
359 }
366 }
360− _ => unreachable!(),
361 }
367 }
362 }
368 }
363 Call::MethodCall(helix_lsp::jsonrpc::MethodCall {
369 Call::MethodCall(helix_lsp::jsonrpc::MethodCall {
364− method,
370+ method, params, id, ..
365− params,
366− jsonrpc,
367− id,
368 }) => {
371 }) => {
369 let call = match MethodCall::parse(&method, params) {
372 let call = match MethodCall::parse(&method, params) {
370 Some(call) => call,
373 Some(call) => call,
helix-term/src/commands.rs+56−58
@@ -60,7 +60,7 @@ pub struct Context<'a> {
60
60
61impl<'a> Context<'a> {
61impl<'a> Context<'a> {
62 /// Push a new component onto the compositor.
62 /// 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>) {
64 self.callback = Some(Box::new(|compositor: &mut Compositor| {
64 self.callback = Some(Box::new(|compositor: &mut Compositor| {
65 compositor.push(component)
65 compositor.push(component)
66 }));
66 }));
@@ -493,7 +493,7 @@ fn extend_next_word_start(cx: &mut Context) {
493 let (view, doc) = current!(cx.editor);
493 let (view, doc) = current!(cx.editor);
494 let text = doc.text().slice(..);
494 let text = doc.text().slice(..);
495
495
496− let selection = doc.selection(view.id).transform(|mut range| {
496+ let selection = doc.selection(view.id).transform(|range| {
497 let word = movement::move_next_word_start(text, range, count);
497 let word = movement::move_next_word_start(text, range, count);
498 let pos = word.head;
498 let pos = word.head;
499 Range::new(range.anchor, pos)
499 Range::new(range.anchor, pos)
@@ -507,7 +507,7 @@ fn extend_prev_word_start(cx: &mut Context) {
507 let (view, doc) = current!(cx.editor);
507 let (view, doc) = current!(cx.editor);
508 let text = doc.text().slice(..);
508 let text = doc.text().slice(..);
509
509
510− let selection = doc.selection(view.id).transform(|mut range| {
510+ let selection = doc.selection(view.id).transform(|range| {
511 let word = movement::move_prev_word_start(text, range, count);
511 let word = movement::move_prev_word_start(text, range, count);
512 let pos = word.head;
512 let pos = word.head;
513 Range::new(range.anchor, pos)
513 Range::new(range.anchor, pos)
@@ -520,7 +520,7 @@ fn extend_next_word_end(cx: &mut Context) {
520 let (view, doc) = current!(cx.editor);
520 let (view, doc) = current!(cx.editor);
521 let text = doc.text().slice(..);
521 let text = doc.text().slice(..);
522
522
523− let selection = doc.selection(view.id).transform(|mut range| {
523+ let selection = doc.selection(view.id).transform(|range| {
524 let word = movement::move_next_word_end(text, range, count);
524 let word = movement::move_next_word_end(text, range, count);
525 let pos = word.head;
525 let pos = word.head;
526 Range::new(range.anchor, pos)
526 Range::new(range.anchor, pos)
@@ -571,7 +571,7 @@ where
571 let (view, doc) = current!(cx.editor);
571 let (view, doc) = current!(cx.editor);
572 let text = doc.text().slice(..);
572 let text = doc.text().slice(..);
573
573
574− let selection = doc.selection(view.id).transform(|mut range| {
574+ let selection = doc.selection(view.id).transform(|range| {
575 search_fn(text, ch, range.head, count, inclusive).map_or(range, |pos| {
575 search_fn(text, ch, range.head, count, inclusive).map_or(range, |pos| {
576 if extend {
576 if extend {
577 Range::new(range.anchor, pos)
577 Range::new(range.anchor, pos)
@@ -929,7 +929,7 @@ fn search_impl(doc: &mut Document, view: &mut View, contents: &str, regex: &Rege
929
929
930// TODO: use one function for search vs extend
930// TODO: use one function for search vs extend
931fn search(cx: &mut Context) {
931fn search(cx: &mut Context) {
932− let (view, doc) = current!(cx.editor);
932+ let (_, doc) = current!(cx.editor);
933
933
934 // TODO: could probably share with select_on_matches?
934 // TODO: could probably share with select_on_matches?
935
935
@@ -937,7 +937,6 @@ fn search(cx: &mut Context) {
937 // feed chunks into the regex yet
937 // feed chunks into the regex yet
938 let contents = doc.text().slice(..).to_string();
938 let contents = doc.text().slice(..).to_string();
939
939
940− let view_id = view.id;
941 let prompt = ui::regex_prompt(
940 let prompt = ui::regex_prompt(
942 cx,
941 cx,
943 "search:".to_string(),
942 "search:".to_string(),
@@ -989,7 +988,7 @@ fn extend_line(cx: &mut Context) {
989 let line_start = text.char_to_line(pos.anchor);
988 let line_start = text.char_to_line(pos.anchor);
990 let start = text.line_to_char(line_start);
989 let start = text.line_to_char(line_start);
991 let line_end = text.char_to_line(pos.head);
990 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));
993
992
994 if pos.anchor == start && pos.head == end && line_end < (text.len_lines() - 2) {
993 if pos.anchor == start && pos.head == end && line_end < (text.len_lines() - 2) {
995 end = line_end_char_index(&text.slice(..), line_end + 1);
994 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
1012 let transaction =
1011 let transaction =
1013 Transaction::change_by_selection(doc.text(), doc.selection(view_id), |range| {
1012 Transaction::change_by_selection(doc.text(), doc.selection(view_id), |range| {
1014 let alltext = doc.text().slice(..);
1013 let alltext = doc.text().slice(..);
1015− let line = alltext.char_to_line(range.head);
1016 let max_to = rope_end_without_line_ending(&alltext);
1014 let max_to = rope_end_without_line_ending(&alltext);
1017 let to = std::cmp::min(max_to, range.to() + 1);
1015 let to = std::cmp::min(max_to, range.to() + 1);
1018 (range.from(), to, None)
1016 (range.from(), to, None)
@@ -1119,7 +1117,7 @@ mod cmd {
1119 pub completer: Option<Completer>,
1117 pub completer: Option<Completer>,
1120 }
1118 }
1121
1119
1122− fn quit(cx: &mut compositor::Context, args: &[&str], event: PromptEvent) {
1120+ fn quit(cx: &mut compositor::Context, _args: &[&str], _event: PromptEvent) {
1123 // last view and we have unsaved changes
1121 // last view and we have unsaved changes
1124 if cx.editor.tree.views().count() == 1 && buffers_remaining_impl(cx.editor) {
1122 if cx.editor.tree.views().count() == 1 && buffers_remaining_impl(cx.editor) {
1125 return;
1123 return;
@@ -1128,12 +1126,12 @@ mod cmd {
1128 .close(view!(cx.editor).id, /* close_buffer */ false);
1126 .close(view!(cx.editor).id, /* close_buffer */ false);
1129 }
1127 }
1130
1128
1131− fn force_quit(cx: &mut compositor::Context, args: &[&str], event: PromptEvent) {
1129+ fn force_quit(cx: &mut compositor::Context, _args: &[&str], _event: PromptEvent) {
1132 cx.editor
1130 cx.editor
1133 .close(view!(cx.editor).id, /* close_buffer */ false);
1131 .close(view!(cx.editor).id, /* close_buffer */ false);
1134 }
1132 }
1135
1133
1136− fn open(cx: &mut compositor::Context, args: &[&str], event: PromptEvent) {
1134+ fn open(cx: &mut compositor::Context, args: &[&str], _event: PromptEvent) {
1137 match args.get(0) {
1135 match args.get(0) {
1138 Some(path) => {
1136 Some(path) => {
1139 // TODO: handle error
1137 // TODO: handle error
@@ -1150,7 +1148,7 @@ mod cmd {
1150 path: Option<P>,
1148 path: Option<P>,
1151 ) -> Result<tokio::task::JoinHandle<Result<(), anyhow::Error>>, anyhow::Error> {
1149 ) -> Result<tokio::task::JoinHandle<Result<(), anyhow::Error>>, anyhow::Error> {
1152 let jobs = &mut cx.jobs;
1150 let jobs = &mut cx.jobs;
1153− let (view, doc) = current!(cx.editor);
1151+ let (_, doc) = current!(cx.editor);
1154
1152
1155 if let Some(path) = path {
1153 if let Some(path) = path {
1156 if let Err(err) = doc.set_path(path.as_ref()) {
1154 if let Err(err) = doc.set_path(path.as_ref()) {
@@ -1174,7 +1172,7 @@ mod cmd {
1174 Ok(tokio::spawn(doc.format_and_save(fmt)))
1172 Ok(tokio::spawn(doc.format_and_save(fmt)))
1175 }
1173 }
1176
1174
1177− fn write(cx: &mut compositor::Context, args: &[&str], event: PromptEvent) {
1175+ fn write(cx: &mut compositor::Context, args: &[&str], _event: PromptEvent) {
1178 match write_impl(cx, args.first()) {
1176 match write_impl(cx, args.first()) {
1179 Err(e) => cx.editor.set_error(e.to_string()),
1177 Err(e) => cx.editor.set_error(e.to_string()),
1180 Ok(handle) => {
1178 Ok(handle) => {
@@ -1184,11 +1182,11 @@ mod cmd {
1184 };
1182 };
1185 }
1183 }
1186
1184
1187− fn new_file(cx: &mut compositor::Context, args: &[&str], event: PromptEvent) {
1185+ fn new_file(cx: &mut compositor::Context, _args: &[&str], _event: PromptEvent) {
1188 cx.editor.new_file(Action::Replace);
1186 cx.editor.new_file(Action::Replace);
1189 }
1187 }
1190
1188
1191− fn format(cx: &mut compositor::Context, args: &[&str], event: PromptEvent) {
1189+ fn format(cx: &mut compositor::Context, _args: &[&str], _event: PromptEvent) {
1192 let (_, doc) = current!(cx.editor);
1190 let (_, doc) = current!(cx.editor);
1193
1191
1194 if let Some(format) = doc.format() {
1192 if let Some(format) = doc.format() {
@@ -1198,7 +1196,7 @@ mod cmd {
1198 }
1196 }
1199 }
1197 }
1200
1198
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) {
1202 use IndentStyle::*;
1200 use IndentStyle::*;
1203
1201
1204 // If no argument, report current indent style.
1202 // If no argument, report current indent style.
@@ -1236,7 +1234,7 @@ mod cmd {
1236 }
1234 }
1237
1235
1238 /// Sets or reports the current document's line ending setting.
1236 /// 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) {
1240 use LineEnding::*;
1238 use LineEnding::*;
1241
1239
1242 // If no argument, report current line ending setting.
1240 // If no argument, report current line ending setting.
@@ -1275,7 +1273,7 @@ mod cmd {
1275 }
1273 }
1276 }
1274 }
1277
1275
1278− fn earlier(cx: &mut compositor::Context, args: &[&str], event: PromptEvent) {
1276+ fn earlier(cx: &mut compositor::Context, args: &[&str], _event: PromptEvent) {
1279 let uk = match args.join(" ").parse::<helix_core::history::UndoKind>() {
1277 let uk = match args.join(" ").parse::<helix_core::history::UndoKind>() {
1280 Ok(uk) => uk,
1278 Ok(uk) => uk,
1281 Err(msg) => {
1279 Err(msg) => {
@@ -1287,7 +1285,7 @@ mod cmd {
1287 doc.earlier(view.id, uk)
1285 doc.earlier(view.id, uk)
1288 }
1286 }
1289
1287
1290− fn later(cx: &mut compositor::Context, args: &[&str], event: PromptEvent) {
1288+ fn later(cx: &mut compositor::Context, args: &[&str], _event: PromptEvent) {
1291 let uk = match args.join(" ").parse::<helix_core::history::UndoKind>() {
1289 let uk = match args.join(" ").parse::<helix_core::history::UndoKind>() {
1292 Ok(uk) => uk,
1290 Ok(uk) => uk,
1293 Err(msg) => {
1291 Err(msg) => {
@@ -1315,7 +1313,6 @@ mod cmd {
1315 }
1313 }
1316
1314
1317 fn force_write_quit(cx: &mut compositor::Context, args: &[&str], event: PromptEvent) {
1315 fn force_write_quit(cx: &mut compositor::Context, args: &[&str], event: PromptEvent) {
1318− let (view, doc) = current!(cx.editor);
1319 match write_impl(cx, args.first()) {
1316 match write_impl(cx, args.first()) {
1320 Ok(handle) => {
1317 Ok(handle) => {
1321 if let Err(e) = helix_lsp::block_on(handle) {
1318 if let Err(e) = helix_lsp::block_on(handle) {
@@ -1357,15 +1354,15 @@ mod cmd {
1357
1354
1358 fn write_all_impl(
1355 fn write_all_impl(
1359 editor: &mut Editor,
1356 editor: &mut Editor,
1360− args: &[&str],
1357+ _args: &[&str],
1361− event: PromptEvent,
1358+ _event: PromptEvent,
1362 quit: bool,
1359 quit: bool,
1363 force: bool,
1360 force: bool,
1364 ) {
1361 ) {
1365 let mut errors = String::new();
1362 let mut errors = String::new();
1366
1363
1367 // save all documents
1364 // save all documents
1368− for (id, mut doc) in &mut editor.documents {
1365+ for (_, doc) in &mut editor.documents {
1369 if doc.path().is_none() {
1366 if doc.path().is_none() {
1370 errors.push_str("cannot write a buffer without a filename\n");
1367 errors.push_str("cannot write a buffer without a filename\n");
1371 continue;
1368 continue;
@@ -1399,7 +1396,7 @@ mod cmd {
1399 write_all_impl(&mut cx.editor, args, event, true, true)
1396 write_all_impl(&mut cx.editor, args, event, true, true)
1400 }
1397 }
1401
1398
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) {
1403 if !force && buffers_remaining_impl(editor) {
1400 if !force && buffers_remaining_impl(editor) {
1404 return;
1401 return;
1405 }
1402 }
@@ -1419,7 +1416,7 @@ mod cmd {
1419 quit_all_impl(&mut cx.editor, args, event, true)
1416 quit_all_impl(&mut cx.editor, args, event, true)
1420 }
1417 }
1421
1418
1422− fn theme(cx: &mut compositor::Context, args: &[&str], event: PromptEvent) {
1419+ fn theme(cx: &mut compositor::Context, args: &[&str], _event: PromptEvent) {
1423 let theme = if let Some(theme) = args.first() {
1420 let theme = if let Some(theme) = args.first() {
1424 theme
1421 theme
1425 } else {
1422 } else {
@@ -1430,11 +1427,15 @@ mod cmd {
1430 cx.editor.set_theme_from_name(theme);
1427 cx.editor.set_theme_from_name(theme);
1431 }
1428 }
1432
1429
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+ ) {
1434 yank_main_selection_to_clipboard_impl(&mut cx.editor);
1435 yank_main_selection_to_clipboard_impl(&mut cx.editor);
1435 }
1436 }
1436
1437
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) {
1438 let (_, doc) = current!(cx.editor);
1439 let (_, doc) = current!(cx.editor);
1439 let separator = args
1440 let separator = args
1440 .first()
1441 .first()
@@ -1443,15 +1444,19 @@ mod cmd {
1443 yank_joined_to_clipboard_impl(&mut cx.editor, separator);
1444 yank_joined_to_clipboard_impl(&mut cx.editor, separator);
1444 }
1445 }
1445
1446
1446− fn paste_clipboard_after(cx: &mut compositor::Context, _: &[&str], _: PromptEvent) {
1447+ fn paste_clipboard_after(cx: &mut compositor::Context, _args: &[&str], _event: PromptEvent) {
1447 paste_clipboard_impl(&mut cx.editor, Paste::After);
1448 paste_clipboard_impl(&mut cx.editor, Paste::After);
1448 }
1449 }
1449
1450
1450− fn paste_clipboard_before(cx: &mut compositor::Context, _: &[&str], _: PromptEvent) {
1451+ fn paste_clipboard_before(cx: &mut compositor::Context, _args: &[&str], _event: PromptEvent) {
1451 paste_clipboard_impl(&mut cx.editor, Paste::After);
1452 paste_clipboard_impl(&mut cx.editor, Paste::After);
1452 }
1453 }
1453
1454
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+ ) {
1455 let (view, doc) = current!(cx.editor);
1460 let (view, doc) = current!(cx.editor);
1456
1461
1457 match cx.editor.clipboard_provider.get_contents() {
1462 match cx.editor.clipboard_provider.get_contents() {
@@ -1470,12 +1475,12 @@ mod cmd {
1470 }
1475 }
1471 }
1476 }
1472
1477
1473− fn show_clipboard_provider(cx: &mut compositor::Context, _: &[&str], _: PromptEvent) {
1478+ fn show_clipboard_provider(cx: &mut compositor::Context, _args: &[&str], _event: PromptEvent) {
1474 cx.editor
1479 cx.editor
1475 .set_status(cx.editor.clipboard_provider.name().into());
1480 .set_status(cx.editor.clipboard_provider.name().into());
1476 }
1481 }
1477
1482
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) {
1479 let dir = match args.first() {
1484 let dir = match args.first() {
1480 Some(dir) => dir,
1485 Some(dir) => dir,
1481 None => {
1486 None => {
@@ -1503,7 +1508,7 @@ mod cmd {
1503 }
1508 }
1504 }
1509 }
1505
1510
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) {
1507 match std::env::current_dir() {
1512 match std::env::current_dir() {
1508 Ok(cwd) => cx
1513 Ok(cwd) => cx
1509 .editor
1514 .editor
@@ -1836,7 +1841,7 @@ fn symbol_picker(cx: &mut Context) {
1836 nested_to_flat(list, file, child);
1841 nested_to_flat(list, file, child);
1837 }
1842 }
1838 }
1843 }
1839− let (view, doc) = current!(cx.editor);
1844+ let (_, doc) = current!(cx.editor);
1840
1845
1841 let language_server = match doc.language_server() {
1846 let language_server = match doc.language_server() {
1842 Some(language_server) => language_server,
1847 Some(language_server) => language_server,
@@ -1927,7 +1932,7 @@ async fn make_format_callback(
1927 format: impl Future<Output = helix_lsp::util::LspFormatting> + Send + 'static,
1932 format: impl Future<Output = helix_lsp::util::LspFormatting> + Send + 'static,
1928) -> anyhow::Result<job::Callback> {
1933) -> anyhow::Result<job::Callback> {
1929 let format = format.await;
1934 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| {
1931 let view_id = view!(editor).id;
1936 let view_id = view!(editor).id;
1932 if let Some(doc) = editor.document_mut(doc_id) {
1937 if let Some(doc) = editor.document_mut(doc_id) {
1933 if doc.version() == doc_version {
1938 if doc.version() == doc_version {
@@ -2101,9 +2106,6 @@ fn goto_mode(cx: &mut Context) {
2101 (_, 't') | (_, 'm') | (_, 'b') => {
2106 (_, 't') | (_, 'm') | (_, 'b') => {
2102 let (view, doc) = current!(cx.editor);
2107 let (view, doc) = current!(cx.editor);
2103
2108
2104− let pos = doc.selection(view.id).cursor();
2105− let line = doc.text().char_to_line(pos);
2106−
2107 let scrolloff = PADDING.min(view.area.height as usize / 2); // TODO: user pref
2109 let scrolloff = PADDING.min(view.area.height as usize / 2); // TODO: user pref
2108
2110
2109 let last_line = view.last_line(doc);
2111 let last_line = view.last_line(doc);
@@ -2152,7 +2154,7 @@ fn goto_impl(
2152 .uri
2154 .uri
2153 .to_file_path()
2155 .to_file_path()
2154 .expect("unable to convert URI to filepath");
2156 .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");
2156 let (view, doc) = current!(editor);
2158 let (view, doc) = current!(editor);
2157 let definition_pos = location.range.start;
2159 let definition_pos = location.range.start;
2158 // TODO: convert inside server
2160 // TODO: convert inside server
@@ -2174,7 +2176,7 @@ fn goto_impl(
2174 editor.set_error("No definition found.".to_string());
2176 editor.set_error("No definition found.".to_string());
2175 }
2177 }
2176 _locations => {
2178 _locations => {
2177− let mut picker = ui::Picker::new(
2179+ let picker = ui::Picker::new(
2178 locations,
2180 locations,
2179 |location| {
2181 |location| {
2180 let file = location.uri.as_str();
2182 let file = location.uri.as_str();
@@ -2341,9 +2343,8 @@ fn goto_pos(editor: &mut Editor, pos: usize) {
2341
2343
2342fn goto_first_diag(cx: &mut Context) {
2344fn goto_first_diag(cx: &mut Context) {
2343 let editor = &mut cx.editor;
2345 let editor = &mut cx.editor;
2344− let (view, doc) = current!(editor);
2346+ let (_, doc) = current!(editor);
2345
2347
2346− let cursor_pos = doc.selection(view.id).cursor();
2347 let diag = if let Some(diag) = doc.diagnostics().first() {
2348 let diag = if let Some(diag) = doc.diagnostics().first() {
2348 diag.range.start
2349 diag.range.start
2349 } else {
2350 } else {
@@ -2355,9 +2356,8 @@ fn goto_first_diag(cx: &mut Context) {
2355
2356
2356fn goto_last_diag(cx: &mut Context) {
2357fn goto_last_diag(cx: &mut Context) {
2357 let editor = &mut cx.editor;
2358 let editor = &mut cx.editor;
2358− let (view, doc) = current!(editor);
2359+ let (_, doc) = current!(editor);
2359
2360
2360− let cursor_pos = doc.selection(view.id).cursor();
2361 let diag = if let Some(diag) = doc.diagnostics().last() {
2361 let diag = if let Some(diag) = doc.diagnostics().last() {
2362 diag.range.start
2362 diag.range.start
2363 } else {
2363 } else {
@@ -2429,8 +2429,8 @@ fn signature_help(cx: &mut Context) {
2429
2429
2430 cx.callback(
2430 cx.callback(
2431 future,
2431 future,
2432− move |editor: &mut Editor,
2432+ move |_editor: &mut Editor,
2433− compositor: &mut Compositor,
2433+ _compositor: &mut Compositor,
2434 response: Option<lsp::SignatureHelp>| {
2434 response: Option<lsp::SignatureHelp>| {
2435 if let Some(signature_help) = response {
2435 if let Some(signature_help) = response {
2436 log::info!("{:?}", signature_help);
2436 log::info!("{:?}", signature_help);
@@ -3002,8 +3002,10 @@ fn format_selections(cx: &mut Context) {
3002 .map(|range| range_to_lsp_range(doc.text(), *range, language_server.offset_encoding()))
3002 .map(|range| range_to_lsp_range(doc.text(), *range, language_server.offset_encoding()))
3003 .collect();
3003 .collect();
3004
3004
3005+ // TODO: all of the TODO's and commented code inside the loop,
3006+ // to make this actually work.
3005− for range in ranges {
3007+ for _range in ranges {
3006− let language_server = match doc.language_server() {
3008+ let _language_server = match doc.language_server() {
3007 Some(language_server) => language_server,
3009 Some(language_server) => language_server,
3008 None => return,
3010 None => return,
3009 };
3011 };
@@ -3051,7 +3053,7 @@ fn join_selections(cx: &mut Context) {
3051 changes.reserve(lines.len());
3053 changes.reserve(lines.len());
3052
3054
3053 for line in lines {
3055 for line in lines {
3054− let mut start = line_end_char_index(&slice, line);
3056+ let start = line_end_char_index(&slice, line);
3055 let mut end = text.line_to_char(line + 1);
3057 let mut end = text.line_to_char(line + 1);
3056 end = skip_while(slice, end, |ch| matches!(ch, ' ' | '\t')).unwrap_or(end);
3058 end = skip_while(slice, end, |ch| matches!(ch, ' ' | '\t')).unwrap_or(end);
3057
3059
@@ -3227,7 +3229,7 @@ fn hover(cx: &mut Context) {
3227 // skip if contents empty
3229 // skip if contents empty
3228
3230
3229 let contents = ui::Markdown::new(contents, editor.syn_loader.clone());
3231 let contents = ui::Markdown::new(contents, editor.syn_loader.clone());
3230− let mut popup = Popup::new(contents);
3232+ let popup = Popup::new(contents);
3231 compositor.push(Box::new(popup));
3233 compositor.push(Box::new(popup));
3232 }
3234 }
3233 },
3235 },
@@ -3271,7 +3273,7 @@ fn match_brackets(cx: &mut Context) {
3271
3273
3272fn jump_forward(cx: &mut Context) {
3274fn jump_forward(cx: &mut Context) {
3273 let count = cx.count();
3275 let count = cx.count();
3274− let (view, doc) = current!(cx.editor);
3276+ let (view, _doc) = current!(cx.editor);
3275
3277
3276 if let Some((id, selection)) = view.jumps.forward(count) {
3278 if let Some((id, selection)) = view.jumps.forward(count) {
3277 view.doc = *id;
3279 view.doc = *id;
@@ -3480,10 +3482,7 @@ fn match_mode(cx: &mut Context) {
3480 'm' => match_brackets(cx),
3482 'm' => match_brackets(cx),
3481 's' => surround_add(cx),
3483 's' => surround_add(cx),
3482 'r' => surround_replace(cx),
3484 'r' => surround_replace(cx),
3483− 'd' => {
3484− surround_delete(cx);
3485+ 'd' => surround_delete(cx),
3485− let (view, doc) = current!(cx.editor);
3486− }
3487 _ => (),
3486 _ => (),
3488 }
3487 }
3489 }
3488 }
@@ -3505,9 +3504,8 @@ fn surround_add(cx: &mut Context) {
3505 let (open, close) = surround::get_pair(ch);
3504 let (open, close) = surround::get_pair(ch);
3506
3505
3507 let mut changes = Vec::new();
3506 let mut changes = Vec::new();
3508− for (i, range) in selection.iter().enumerate() {
3507+ for range in selection.iter() {
3509 let from = range.from();
3508 let from = range.from();
3510− let line = text.char_to_line(range.to());
3511 let max_to = rope_end_without_line_ending(&text);
3509 let max_to = rope_end_without_line_ending(&text);
3512 let to = std::cmp::min(range.to() + 1, max_to);
3510 let to = std::cmp::min(range.to() + 1, max_to);
3513
3511
helix-term/src/compositor.rs+5−6
@@ -35,7 +35,7 @@ pub struct Context<'a> {
35
35
36pub trait Component: Any + AnyComponent {
36pub trait Component: Any + AnyComponent {
37 /// Process input events, return true if handled.
37 /// 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 {
39 EventResult::Ignored
39 EventResult::Ignored
40 }
40 }
41 // , args: ()
41 // , args: ()
@@ -49,13 +49,13 @@ pub trait Component: Any + AnyComponent {
49 fn render(&self, area: Rect, frame: &mut Surface, ctx: &mut Context);
49 fn render(&self, area: Rect, frame: &mut Surface, ctx: &mut Context);
50
50
51 /// Get cursor position and cursor kind.
51 /// 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) {
53 (None, CursorKind::Hidden)
53 (None, CursorKind::Hidden)
54 }
54 }
55
55
56 /// May be used by the parent component to compute the child area.
56 /// May be used by the parent component to compute the child area.
57 /// viewport is the maximum allowed area, and the child should stay within those bounds.
57 /// 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)> {
59 // TODO: for scrolling, the scroll wrapper should place a size + offset on the Context
59 // TODO: for scrolling, the scroll wrapper should place a size + offset on the Context
60 // that way render can use it
60 // that way render can use it
61 None
61 None
@@ -79,7 +79,7 @@ pub struct Compositor {
79impl Compositor {
79impl Compositor {
80 pub fn new() -> Result<Self, Error> {
80 pub fn new() -> Result<Self, Error> {
81 let backend = CrosstermBackend::new(stdout());
81 let backend = CrosstermBackend::new(stdout());
82− let mut terminal = Terminal::new(backend)?;
82+ let terminal = Terminal::new(backend)?;
83 Ok(Self {
83 Ok(Self {
84 layers: Vec::new(),
84 layers: Vec::new(),
85 terminal,
85 terminal,
@@ -124,8 +124,7 @@ impl Compositor {
124 }
124 }
125
125
126 pub fn render(&mut self, cx: &mut Context) {
126 pub fn render(&mut self, cx: &mut Context) {
127− let area = self
128− .terminal
127+ self.terminal
129 .autoresize()
128 .autoresize()
130 .expect("Unable to determine terminal size");
129 .expect("Unable to determine terminal size");
131
130
helix-term/src/ui/completion.rs+1−1
@@ -76,7 +76,7 @@ impl Completion {
76 trigger_offset: usize,
76 trigger_offset: usize,
77 ) -> Self {
77 ) -> Self {
78 // let items: Vec<CompletionItem> = Vec::new();
78 // 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| {
80 match event {
80 match event {
81 PromptEvent::Abort => {}
81 PromptEvent::Abort => {}
82 PromptEvent::Validate => {
82 PromptEvent::Validate => {
helix-term/src/ui/editor.rs+4−5
@@ -392,7 +392,7 @@ impl EditorView {
392 viewport: Rect,
392 viewport: Rect,
393 surface: &mut Surface,
393 surface: &mut Surface,
394 theme: &Theme,
394 theme: &Theme,
395− is_focused: bool,
395+ _is_focused: bool,
396 ) {
396 ) {
397 use helix_core::diagnostic::Severity;
397 use helix_core::diagnostic::Severity;
398 use tui::{
398 use tui::{
@@ -402,7 +402,6 @@ impl EditorView {
402 };
402 };
403
403
404 let cursor = doc.selection(view.id).cursor();
404 let cursor = doc.selection(view.id).cursor();
405− let line = doc.text().char_to_line(cursor);
406
405
407 let diagnostics = doc.diagnostics().iter().filter(|diagnostic| {
406 let diagnostics = doc.diagnostics().iter().filter(|diagnostic| {
408 diagnostic.range.start <= cursor && diagnostic.range.end >= cursor
407 diagnostic.range.start <= cursor && diagnostic.range.end >= cursor
@@ -608,7 +607,7 @@ impl Component for EditorView {
608 // clear status
607 // clear status
609 cx.editor.status_msg = None;
608 cx.editor.status_msg = None;
610
609
611− let (view, doc) = current!(cx.editor);
610+ let (_, doc) = current!(cx.editor);
612 let mode = doc.mode();
611 let mode = doc.mode();
613
612
614 let mut cxt = commands::Context {
613 let mut cxt = commands::Context {
@@ -705,7 +704,7 @@ impl Component for EditorView {
705 }
704 }
706 }
705 }
707
706
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) {
709 // clear with background color
708 // clear with background color
710 surface.set_style(area, cx.editor.theme.get("ui.background"));
709 surface.set_style(area, cx.editor.theme.get("ui.background"));
711
710
@@ -741,7 +740,7 @@ impl Component for EditorView {
741 }
740 }
742 }
741 }
743
742
744− fn cursor(&self, area: Rect, editor: &Editor) -> (Option<Position>, CursorKind) {
743+ fn cursor(&self, _area: Rect, editor: &Editor) -> (Option<Position>, CursorKind) {
745 // match view.doc.mode() {
744 // match view.doc.mode() {
746 // Mode::Insert => write!(stdout, "\x1B[6 q"),
745 // Mode::Insert => write!(stdout, "\x1B[6 q"),
747 // mode => write!(stdout, "\x1B[2 q"),
746 // mode => write!(stdout, "\x1B[2 q"),
helix-term/src/ui/markdown.rs+5−5
@@ -40,8 +40,8 @@ fn parse<'a>(
40 theme: Option<&Theme>,
40 theme: Option<&Theme>,
41 loader: &syntax::Loader,
41 loader: &syntax::Loader,
42) -> tui::text::Text<'a> {
42) -> 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}}}
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```";
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```";
45
45
46 let mut options = Options::empty();
46 let mut options = Options::empty();
47 options.insert(Options::ENABLE_STRIKETHROUGH);
47 options.insert(Options::ENABLE_STRIKETHROUGH);
@@ -92,7 +92,7 @@ fn parse<'a>(
92 .and_then(|config| config.highlight_config(theme.scopes()))
92 .and_then(|config| config.highlight_config(theme.scopes()))
93 .map(|config| Syntax::new(&rope, config));
93 .map(|config| Syntax::new(&rope, config));
94
94
95− if let Some(mut syntax) = syntax {
95+ if let Some(syntax) = syntax {
96 // if we have a syntax available, highlight_iter and generate spans
96 // if we have a syntax available, highlight_iter and generate spans
97 let mut highlights = Vec::new();
97 let mut highlights = Vec::new();
98
98
@@ -142,13 +142,13 @@ fn parse<'a>(
142 }
142 }
143 } else {
143 } else {
144 for line in text.lines() {
144 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);
146 lines.push(Spans::from(span));
146 lines.push(Spans::from(span));
147 }
147 }
148 }
148 }
149 } else {
149 } else {
150 for line in text.lines() {
150 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);
152 lines.push(Spans::from(span));
152 lines.push(Spans::from(span));
153 }
153 }
154 }
154 }
helix-term/src/ui/menu.rs+1−2
@@ -58,7 +58,6 @@ impl<T: Item> Menu<T> {
58 pub fn score(&mut self, pattern: &str) {
58 pub fn score(&mut self, pattern: &str) {
59 // need to borrow via pattern match otherwise it complains about simultaneous borrow
59 // need to borrow via pattern match otherwise it complains about simultaneous borrow
60 let Self {
60 let Self {
61− ref mut options,
62 ref mut matcher,
61 ref mut matcher,
63 ref mut matches,
62 ref mut matches,
64 ..
63 ..
@@ -291,7 +290,7 @@ impl<T: Item + 'static> Component for Menu<T> {
291 // )
290 // )
292 // }
291 // }
293
292
294− for (i, option) in (scroll..(scroll + win_height).min(len)).enumerate() {
293+ for (i, _) in (scroll..(scroll + win_height).min(len)).enumerate() {
295 let is_marked = i >= scroll_line && i < scroll_line + scroll_height;
294 let is_marked = i >= scroll_line && i < scroll_line + scroll_height;
296
295
297 if is_marked {
296 if is_marked {
helix-term/src/ui/mod.rs+7−7
@@ -35,7 +35,7 @@ pub fn regex_prompt(
35
35
36 Prompt::new(
36 Prompt::new(
37 prompt,
37 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
39 move |cx: &mut crate::compositor::Context, input: &str, event: PromptEvent| {
39 move |cx: &mut crate::compositor::Context, input: &str, event: PromptEvent| {
40 match event {
40 match event {
41 PromptEvent::Abort => {
41 PromptEvent::Abort => {
@@ -118,7 +118,7 @@ pub fn file_picker(root: PathBuf) -> Picker<PathBuf> {
118 .into()
118 .into()
119 },
119 },
120 move |editor: &mut Editor, path: &PathBuf, action| {
120 move |editor: &mut Editor, path: &PathBuf, action| {
121− let document_id = editor
121+ editor
122 .open(path.into(), action)
122 .open(path.into(), action)
123 .expect("editor.open failed");
123 .expect("editor.open failed");
124 },
124 },
@@ -151,7 +151,7 @@ pub mod completers {
151
151
152 let mut matches: Vec<_> = names
152 let mut matches: Vec<_> = names
153 .into_iter()
153 .into_iter()
154− .filter_map(|(range, name)| {
154+ .filter_map(|(_range, name)| {
155 matcher.fuzzy_match(&name, input).map(|score| (name, score))
155 matcher.fuzzy_match(&name, input).map(|score| (name, score))
156 })
156 })
157 .collect();
157 .collect();
@@ -226,7 +226,7 @@ pub mod completers {
226 (path, file_name)
226 (path, file_name)
227 };
227 };
228
228
229− let end = (input.len()..);
229+ let end = input.len()..;
230
230
231 let mut files: Vec<_> = WalkBuilder::new(dir.clone())
231 let mut files: Vec<_> = WalkBuilder::new(dir.clone())
232 .max_depth(Some(1))
232 .max_depth(Some(1))
@@ -239,7 +239,7 @@ pub mod completers {
239 return None;
239 return None;
240 }
240 }
241
241
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());
243
243
244 let path = entry.path();
244 let path = entry.path();
245 let mut path = if is_tilde {
245 let mut path = if is_tilde {
@@ -271,14 +271,14 @@ pub mod completers {
271 // inefficient, but we need to calculate the scores, filter out None, then sort.
271 // inefficient, but we need to calculate the scores, filter out None, then sort.
272 let mut matches: Vec<_> = files
272 let mut matches: Vec<_> = files
273 .into_iter()
273 .into_iter()
274− .filter_map(|(range, file)| {
274+ .filter_map(|(_range, file)| {
275 matcher
275 matcher
276 .fuzzy_match(&file, &file_name)
276 .fuzzy_match(&file, &file_name)
277 .map(|score| (file, score))
277 .map(|score| (file, score))
278 })
278 })
279 .collect();
279 .collect();
280
280
281− let range = ((input.len().saturating_sub(file_name.len()))..);
281+ let range = (input.len().saturating_sub(file_name.len()))..;
282
282
283 matches.sort_unstable_by_key(|(_file, score)| Reverse(*score));
283 matches.sort_unstable_by_key(|(_file, score)| Reverse(*score));
284 files = matches
284 files = matches
helix-term/src/ui/picker.rs+2−3
@@ -43,8 +43,8 @@ impl<T> Picker<T> {
43 ) -> Self {
43 ) -> Self {
44 let prompt = Prompt::new(
44 let prompt = Prompt::new(
45 "".to_string(),
45 "".to_string(),
46− |pattern: &str| Vec::new(),
46+ |_pattern: &str| Vec::new(),
47− |editor: &mut Context, pattern: &str, event: PromptEvent| {
47+ |_editor: &mut Context, _pattern: &str, _event: PromptEvent| {
48 //
48 //
49 },
49 },
50 );
50 );
@@ -69,7 +69,6 @@ impl<T> Picker<T> {
69 pub fn score(&mut self) {
69 pub fn score(&mut self) {
70 // need to borrow via pattern match otherwise it complains about simultaneous borrow
70 // need to borrow via pattern match otherwise it complains about simultaneous borrow
71 let Self {
71 let Self {
72− ref mut options,
73 ref mut matcher,
72 ref mut matcher,
74 ref mut matches,
73 ref mut matches,
75 ref filters,
74 ref filters,
helix-term/src/ui/popup.rs+2−3
@@ -52,7 +52,7 @@ impl<T: Component> Component for Popup<T> {
52 fn handle_event(&mut self, event: Event, cx: &mut Context) -> EventResult {
52 fn handle_event(&mut self, event: Event, cx: &mut Context) -> EventResult {
53 let key = match event {
53 let key = match event {
54 Event::Key(event) => event,
54 Event::Key(event) => event,
55− Event::Resize(width, height) => {
55+ Event::Resize(_, _) => {
56 // TODO: calculate inner area, call component's handle_event with that area
56 // TODO: calculate inner area, call component's handle_event with that area
57 return EventResult::Ignored;
57 return EventResult::Ignored;
58 }
58 }
@@ -94,7 +94,7 @@ impl<T: Component> Component for Popup<T> {
94 // tab/enter/ctrl-k or whatever will confirm the selection/ ctrl-n/ctrl-p for scroll.
94 // tab/enter/ctrl-k or whatever will confirm the selection/ ctrl-n/ctrl-p for scroll.
95 }
95 }
96
96
97− fn required_size(&mut self, viewport: (u16, u16)) -> Option<(u16, u16)> {
97+ fn required_size(&mut self, _viewport: (u16, u16)) -> Option<(u16, u16)> {
98 let (width, height) = self
98 let (width, height) = self
99 .contents
99 .contents
100 .required_size((120, 26)) // max width, max height
100 .required_size((120, 26)) // max width, max height
@@ -130,7 +130,6 @@ impl<T: Component> Component for Popup<T> {
130 rel_y += 1 // position below point
130 rel_y += 1 // position below point
131 }
131 }
132
132
133− let area = Rect::new(rel_x, rel_y, width, height);
134 // clip to viewport
133 // clip to viewport
135 let area = viewport.intersection(Rect::new(rel_x, rel_y, width, height));
134 let area = viewport.intersection(Rect::new(rel_x, rel_y, width, height));
136
135
helix-term/src/ui/prompt.rs+17−17
@@ -396,6 +396,22 @@ impl Component for Prompt {
396 (self.callback_fn)(cx, &self.line, PromptEvent::Abort);
396 (self.callback_fn)(cx, &self.line, PromptEvent::Abort);
397 return close_fn;
397 return close_fn;
398 }
398 }
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)),
399 KeyEvent {
415 KeyEvent {
400 code: KeyCode::Char('f'),
416 code: KeyCode::Char('f'),
401 modifiers: KeyModifiers::CONTROL,
417 modifiers: KeyModifiers::CONTROL,
@@ -428,22 +444,6 @@ impl Component for Prompt {
428 code: KeyCode::Char('a'),
444 code: KeyCode::Char('a'),
429 modifiers: KeyModifiers::CONTROL,
445 modifiers: KeyModifiers::CONTROL,
430 } => self.move_start(),
446 } => 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)),
447 KeyEvent {
447 KeyEvent {
448 code: KeyCode::Char('w'),
448 code: KeyCode::Char('w'),
449 modifiers: KeyModifiers::CONTROL,
449 modifiers: KeyModifiers::CONTROL,
@@ -492,7 +492,7 @@ impl Component for Prompt {
492 self.render_prompt(area, surface, cx)
492 self.render_prompt(area, surface, cx)
493 }
493 }
494
494
495− fn cursor(&self, area: Rect, editor: &Editor) -> (Option<Position>, CursorKind) {
495+ fn cursor(&self, area: Rect, _editor: &Editor) -> (Option<Position>, CursorKind) {
496 let line = area.height as usize - 1;
496 let line = area.height as usize - 1;
497 (
497 (
498 Some(Position::new(
498 Some(Position::new(
helix-term/src/ui/text.rs+1−3
@@ -13,12 +13,10 @@ impl Text {
13 }
13 }
14}
14}
15impl Component for Text {
15impl 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) {
17 use tui::widgets::{Paragraph, Widget, Wrap};
17 use tui::widgets::{Paragraph, Widget, Wrap};
18 let contents = tui::text::Text::from(self.contents.clone());
18 let contents = tui::text::Text::from(self.contents.clone());
19
19
20− let style = cx.editor.theme.get("ui.text");
21−
22 let par = Paragraph::new(contents).wrap(Wrap { trim: false });
20 let par = Paragraph::new(contents).wrap(Wrap { trim: false });
23 // .scroll(x, y) offsets
21 // .scroll(x, y) offsets
24
22