on master help sign in
clippy warnings
commit3feb00283df92b8865c9cf7baba0e2ab06dcc028 authorBlaž Hrastnik <blaz@mxxn.io> dateTue 29 Sep 2020, 18:02 (6 years ago) parent1bb01d2
6 files changed+21−22
helix-core/src/state.rs+1−2 helix-core/src/syntax.rs+7−7 helix-term/src/editor.rs+3−4 helix-view/src/commands.rs+7−7 helix-view/src/theme.rs+1 helix-view/src/view.rs+2−2
helix-core/src/state.rs+1−2
@@ -358,7 +358,7 @@ where
358358{
359359 let mut chars = slice.chars_at(*pos);
360360
361− while let Some(ch) = chars.next() {
361+ for ch in chars {
362362 if !fun(ch) {
363363 break;
364364 }
@@ -372,7 +372,6 @@ where
372372{
373373 // need to +1 so that prev() includes current char
374374 let mut chars = slice.chars_at(*pos + 1);
375− let mut chars = slice.chars_at(*pos + 1);
376375
377376 while let Some(ch) = chars.prev() {
378377 if !fun(ch) {
helix-core/src/syntax.rs+7−7
@@ -37,11 +37,11 @@ impl LanguageConfiguration {
3737
3838 let highlights_query =
3939 std::fs::read_to_string(self.path.join("queries/highlights.scm"))
40− .unwrap_or(String::new());
40+ .unwrap_or_default();
4141
4242 let injections_query =
4343 std::fs::read_to_string(self.path.join("queries/injections.scm"))
44− .unwrap_or(String::new());
44+ .unwrap_or_default();
4545
4646 let locals_query = "";
4747
@@ -66,7 +66,7 @@ impl LanguageConfiguration {
6666
6767use once_cell::sync::Lazy;
6868
69−pub(crate) static LOADER: Lazy<Loader> = Lazy::new(|| Loader::init());
69+pub(crate) static LOADER: Lazy<Loader> = Lazy::new(Loader::init);
7070
7171pub struct Loader {
7272 // highlight_names ?
@@ -159,7 +159,7 @@ impl Syntax {
159159 // let grammar = get_language(&language);
160160 let parser = Parser::new();
161161
162− let root_layer = LanguageLayer::new();
162+ let root_layer = LanguageLayer { tree: None };
163163
164164 // track markers of injections
165165 // track scope_descriptor: a Vec of scopes for item in tree
@@ -317,9 +317,9 @@ use crate::transaction::{ChangeSet, Operation};
317317use crate::Tendril;
318318
319319impl LanguageLayer {
320− pub fn new() -> Self {
321− Self { tree: None }
322− }
320+ // pub fn new() -> Self {
321+ // Self { tree: None }
322+ // }
323323
324324 fn tree(&self) -> &Tree {
325325 // TODO: no unwrap
helix-term/src/editor.rs+3−4
@@ -209,12 +209,11 @@ impl Editor {
209209 }
210210 }
211211
212− let mut line = 0;
213212 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() {
215214 self.surface
216− .set_stringn(0, line, format!("{:>5}", i + 1), 5, style); // lavender
217− line += 1;
215+ .set_stringn(0, line, format!("{:>5}", i + 1), 5, style);
216+ // lavender
218217 }
219218
220219 // let lines = state
helix-view/src/commands.rs+7−7
@@ -42,7 +42,7 @@ pub fn move_line_down(view: &mut View, count: usize) {
4242 .move_selection(Direction::Forward, Granularity::Line, count);
4343}
4444
45−pub fn move_line_end(view: &mut View, count: usize) {
45+pub fn move_line_end(view: &mut View, _count: usize) {
4646 // TODO: use a transaction
4747 let lines = selection_lines(&view.state);
4848
@@ -64,7 +64,7 @@ pub fn move_line_end(view: &mut View, count: usize) {
6464 transaction.apply(&mut view.state);
6565}
6666
67−pub fn move_line_start(view: &mut View, count: usize) {
67+pub fn move_line_start(view: &mut View, _count: usize) {
6868 let lines = selection_lines(&view.state);
6969
7070 let positions = lines
@@ -208,24 +208,24 @@ fn selection_lines(state: &State) -> Vec<usize> {
208208 .map(|range| state.doc.char_to_line(range.head))
209209 .collect::<Vec<_>>();
210210
211− lines.sort();
211+ lines.sort_unstable(); // sorting by usize so _unstable is preferred
212212 lines.dedup();
213213
214214 lines
215215}
216216
217217// 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) {
219219 view.state.mode = Mode::Insert;
220220
221− move_line_start(view, _count);
221+ move_line_start(view, count);
222222}
223223
224224// 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) {
226226 view.state.mode = Mode::Insert;
227227
228− move_line_end(view, _count);
228+ move_line_end(view, count);
229229}
230230
231231// o inserts a new line after each line with a selection
helix-view/src/theme.rs+1
@@ -173,6 +173,7 @@ impl Theme {
173173 .unwrap_or_else(|| Style::default().fg(Color::Rgb(0, 0, 255)))
174174 }
175175
176+ #[inline]
176177 pub fn scopes(&self) -> &[String] {
177178 &self.scopes
178179 }
helix-view/src/view.rs+2−2
@@ -13,11 +13,11 @@ pub struct View {
1313}
1414
1515impl 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> {
1717 let theme = Theme::default();
1818 let state = State::load(path, theme.scopes())?;
1919
20− let view = View {
20+ let view = Self {
2121 state,
2222 first_line: 0,
2323 size, // TODO: pass in from term