on master help sign in
clippy warnings
3feb002Blaž Hrastnik
helix-core/src/state.rs+1−2
@@ -358,7 +358,7 @@ where
358{
358{
359 let mut chars = slice.chars_at(*pos);
359 let mut chars = slice.chars_at(*pos);
360
360
361− while let Some(ch) = chars.next() {
361+ for ch in chars {
362 if !fun(ch) {
362 if !fun(ch) {
363 break;
363 break;
364 }
364 }
@@ -372,7 +372,6 @@ where
372{
372{
373 // need to +1 so that prev() includes current char
373 // need to +1 so that prev() includes current char
374 let mut chars = slice.chars_at(*pos + 1);
374 let mut chars = slice.chars_at(*pos + 1);
375− let mut chars = slice.chars_at(*pos + 1);
376
375
377 while let Some(ch) = chars.prev() {
376 while let Some(ch) = chars.prev() {
378 if !fun(ch) {
377 if !fun(ch) {
helix-core/src/syntax.rs+7−7
@@ -37,11 +37,11 @@ impl LanguageConfiguration {
37
37
38 let highlights_query =
38 let highlights_query =
39 std::fs::read_to_string(self.path.join("queries/highlights.scm"))
39 std::fs::read_to_string(self.path.join("queries/highlights.scm"))
40− .unwrap_or(String::new());
40+ .unwrap_or_default();
41
41
42 let injections_query =
42 let injections_query =
43 std::fs::read_to_string(self.path.join("queries/injections.scm"))
43 std::fs::read_to_string(self.path.join("queries/injections.scm"))
44− .unwrap_or(String::new());
44+ .unwrap_or_default();
45
45
46 let locals_query = "";
46 let locals_query = "";
47
47
@@ -66,7 +66,7 @@ impl LanguageConfiguration {
66
66
67use once_cell::sync::Lazy;
67use once_cell::sync::Lazy;
68
68
69−pub(crate) static LOADER: Lazy<Loader> = Lazy::new(|| Loader::init());
69+pub(crate) static LOADER: Lazy<Loader> = Lazy::new(Loader::init);
70
70
71pub struct Loader {
71pub struct Loader {
72 // highlight_names ?
72 // highlight_names ?
@@ -159,7 +159,7 @@ impl Syntax {
159 // let grammar = get_language(&language);
159 // let grammar = get_language(&language);
160 let parser = Parser::new();
160 let parser = Parser::new();
161
161
162− let root_layer = LanguageLayer::new();
162+ let root_layer = LanguageLayer { tree: None };
163
163
164 // track markers of injections
164 // track markers of injections
165 // track scope_descriptor: a Vec of scopes for item in tree
165 // track scope_descriptor: a Vec of scopes for item in tree
@@ -317,9 +317,9 @@ use crate::transaction::{ChangeSet, Operation};
317use crate::Tendril;
317use crate::Tendril;
318
318
319impl LanguageLayer {
319impl LanguageLayer {
320− pub fn new() -> Self {
320+ // pub fn new() -> Self {
321− Self { tree: None }
321+ // Self { tree: None }
322− }
322+ // }
323
323
324 fn tree(&self) -> &Tree {
324 fn tree(&self) -> &Tree {
325 // TODO: no unwrap
325 // TODO: no unwrap
helix-term/src/editor.rs+3−4
@@ -209,12 +209,11 @@ impl Editor {
209 }
209 }
210 }
210 }
211
211
212− let mut line = 0;
213 let style: Style = view.theme.get("ui.linenr").into();
212 let style: Style = view.theme.get("ui.linenr").into();
214− for i in view.first_line..(last_line as u16) {
213+ for (i, line) in (view.first_line..(last_line as u16)).enumerate() {
215 self.surface
214 self.surface
216− .set_stringn(0, line, format!("{:>5}", i + 1), 5, style); // lavender
215+ .set_stringn(0, line, format!("{:>5}", i + 1), 5, style);
217− line += 1;
216+ // lavender
218 }
217 }
219
218
220 // let lines = state
219 // let lines = state
helix-view/src/commands.rs+7−7
@@ -42,7 +42,7 @@ pub fn move_line_down(view: &mut View, count: usize) {
42 .move_selection(Direction::Forward, Granularity::Line, count);
42 .move_selection(Direction::Forward, Granularity::Line, count);
43}
43}
44
44
45−pub fn move_line_end(view: &mut View, count: usize) {
45+pub fn move_line_end(view: &mut View, _count: usize) {
46 // TODO: use a transaction
46 // TODO: use a transaction
47 let lines = selection_lines(&view.state);
47 let lines = selection_lines(&view.state);
48
48
@@ -64,7 +64,7 @@ pub fn move_line_end(view: &mut View, count: usize) {
64 transaction.apply(&mut view.state);
64 transaction.apply(&mut view.state);
65}
65}
66
66
67−pub fn move_line_start(view: &mut View, count: usize) {
67+pub fn move_line_start(view: &mut View, _count: usize) {
68 let lines = selection_lines(&view.state);
68 let lines = selection_lines(&view.state);
69
69
70 let positions = lines
70 let positions = lines
@@ -208,24 +208,24 @@ fn selection_lines(state: &State) -> Vec<usize> {
208 .map(|range| state.doc.char_to_line(range.head))
208 .map(|range| state.doc.char_to_line(range.head))
209 .collect::<Vec<_>>();
209 .collect::<Vec<_>>();
210
210
211− lines.sort();
211+ lines.sort_unstable(); // sorting by usize so _unstable is preferred
212 lines.dedup();
212 lines.dedup();
213
213
214 lines
214 lines
215}
215}
216
216
217// I inserts at the start of each line with a selection
217// I inserts at the start of each line with a selection
218−pub fn prepend_to_line(view: &mut View, _count: usize) {
218+pub fn prepend_to_line(view: &mut View, count: usize) {
219 view.state.mode = Mode::Insert;
219 view.state.mode = Mode::Insert;
220
220
221− move_line_start(view, _count);
221+ move_line_start(view, count);
222}
222}
223
223
224// A inserts at the end of each line with a selection
224// A inserts at the end of each line with a selection
225−pub fn append_to_line(view: &mut View, _count: usize) {
225+pub fn append_to_line(view: &mut View, count: usize) {
226 view.state.mode = Mode::Insert;
226 view.state.mode = Mode::Insert;
227
227
228− move_line_end(view, _count);
228+ move_line_end(view, count);
229}
229}
230
230
231// o inserts a new line after each line with a selection
231// o inserts a new line after each line with a selection
helix-view/src/theme.rs+1
@@ -173,6 +173,7 @@ impl Theme {
173 .unwrap_or_else(|| Style::default().fg(Color::Rgb(0, 0, 255)))
173 .unwrap_or_else(|| Style::default().fg(Color::Rgb(0, 0, 255)))
174 }
174 }
175
175
176+ #[inline]
176 pub fn scopes(&self) -> &[String] {
177 pub fn scopes(&self) -> &[String] {
177 &self.scopes
178 &self.scopes
178 }
179 }
helix-view/src/view.rs+2−2
@@ -13,11 +13,11 @@ pub struct View {
13}
13}
14
14
15impl View {
15impl View {
16− pub fn open(path: PathBuf, size: (u16, u16)) -> Result<View, Error> {
16+ pub fn open(path: PathBuf, size: (u16, u16)) -> Result<Self, Error> {
17 let theme = Theme::default();
17 let theme = Theme::default();
18 let state = State::load(path, theme.scopes())?;
18 let state = State::load(path, theme.scopes())?;
19
19
20− let view = View {
20+ let view = Self {
21 state,
21 state,
22 first_line: 0,
22 first_line: 0,
23 size, // TODO: pass in from term
23 size, // TODO: pass in from term