clippy warnings
This commit is contained in:
parent
1bb01d27ae
commit
3feb00283d
6 changed files with 21 additions and 22 deletions
|
@ -358,7 +358,7 @@ where
|
|||
{
|
||||
let mut chars = slice.chars_at(*pos);
|
||||
|
||||
while let Some(ch) = chars.next() {
|
||||
for ch in chars {
|
||||
if !fun(ch) {
|
||||
break;
|
||||
}
|
||||
|
@ -372,7 +372,6 @@ where
|
|||
{
|
||||
// need to +1 so that prev() includes current char
|
||||
let mut chars = slice.chars_at(*pos + 1);
|
||||
let mut chars = slice.chars_at(*pos + 1);
|
||||
|
||||
while let Some(ch) = chars.prev() {
|
||||
if !fun(ch) {
|
||||
|
|
|
@ -37,11 +37,11 @@ impl LanguageConfiguration {
|
|||
|
||||
let highlights_query =
|
||||
std::fs::read_to_string(self.path.join("queries/highlights.scm"))
|
||||
.unwrap_or(String::new());
|
||||
.unwrap_or_default();
|
||||
|
||||
let injections_query =
|
||||
std::fs::read_to_string(self.path.join("queries/injections.scm"))
|
||||
.unwrap_or(String::new());
|
||||
.unwrap_or_default();
|
||||
|
||||
let locals_query = "";
|
||||
|
||||
|
@ -66,7 +66,7 @@ impl LanguageConfiguration {
|
|||
|
||||
use once_cell::sync::Lazy;
|
||||
|
||||
pub(crate) static LOADER: Lazy<Loader> = Lazy::new(|| Loader::init());
|
||||
pub(crate) static LOADER: Lazy<Loader> = Lazy::new(Loader::init);
|
||||
|
||||
pub struct Loader {
|
||||
// highlight_names ?
|
||||
|
@ -159,7 +159,7 @@ impl Syntax {
|
|||
// let grammar = get_language(&language);
|
||||
let parser = Parser::new();
|
||||
|
||||
let root_layer = LanguageLayer::new();
|
||||
let root_layer = LanguageLayer { tree: None };
|
||||
|
||||
// track markers of injections
|
||||
// track scope_descriptor: a Vec of scopes for item in tree
|
||||
|
@ -317,9 +317,9 @@ use crate::transaction::{ChangeSet, Operation};
|
|||
use crate::Tendril;
|
||||
|
||||
impl LanguageLayer {
|
||||
pub fn new() -> Self {
|
||||
Self { tree: None }
|
||||
}
|
||||
// pub fn new() -> Self {
|
||||
// Self { tree: None }
|
||||
// }
|
||||
|
||||
fn tree(&self) -> &Tree {
|
||||
// TODO: no unwrap
|
||||
|
|
|
@ -209,12 +209,11 @@ impl Editor {
|
|||
}
|
||||
}
|
||||
|
||||
let mut line = 0;
|
||||
let style: Style = view.theme.get("ui.linenr").into();
|
||||
for i in view.first_line..(last_line as u16) {
|
||||
for (i, line) in (view.first_line..(last_line as u16)).enumerate() {
|
||||
self.surface
|
||||
.set_stringn(0, line, format!("{:>5}", i + 1), 5, style); // lavender
|
||||
line += 1;
|
||||
.set_stringn(0, line, format!("{:>5}", i + 1), 5, style);
|
||||
// lavender
|
||||
}
|
||||
|
||||
// let lines = state
|
||||
|
|
|
@ -42,7 +42,7 @@ pub fn move_line_down(view: &mut View, count: usize) {
|
|||
.move_selection(Direction::Forward, Granularity::Line, count);
|
||||
}
|
||||
|
||||
pub fn move_line_end(view: &mut View, count: usize) {
|
||||
pub fn move_line_end(view: &mut View, _count: usize) {
|
||||
// TODO: use a transaction
|
||||
let lines = selection_lines(&view.state);
|
||||
|
||||
|
@ -64,7 +64,7 @@ pub fn move_line_end(view: &mut View, count: usize) {
|
|||
transaction.apply(&mut view.state);
|
||||
}
|
||||
|
||||
pub fn move_line_start(view: &mut View, count: usize) {
|
||||
pub fn move_line_start(view: &mut View, _count: usize) {
|
||||
let lines = selection_lines(&view.state);
|
||||
|
||||
let positions = lines
|
||||
|
@ -208,24 +208,24 @@ fn selection_lines(state: &State) -> Vec<usize> {
|
|||
.map(|range| state.doc.char_to_line(range.head))
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
lines.sort();
|
||||
lines.sort_unstable(); // sorting by usize so _unstable is preferred
|
||||
lines.dedup();
|
||||
|
||||
lines
|
||||
}
|
||||
|
||||
// I inserts at the start of each line with a selection
|
||||
pub fn prepend_to_line(view: &mut View, _count: usize) {
|
||||
pub fn prepend_to_line(view: &mut View, count: usize) {
|
||||
view.state.mode = Mode::Insert;
|
||||
|
||||
move_line_start(view, _count);
|
||||
move_line_start(view, count);
|
||||
}
|
||||
|
||||
// A inserts at the end of each line with a selection
|
||||
pub fn append_to_line(view: &mut View, _count: usize) {
|
||||
pub fn append_to_line(view: &mut View, count: usize) {
|
||||
view.state.mode = Mode::Insert;
|
||||
|
||||
move_line_end(view, _count);
|
||||
move_line_end(view, count);
|
||||
}
|
||||
|
||||
// o inserts a new line after each line with a selection
|
||||
|
|
|
@ -173,6 +173,7 @@ impl Theme {
|
|||
.unwrap_or_else(|| Style::default().fg(Color::Rgb(0, 0, 255)))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn scopes(&self) -> &[String] {
|
||||
&self.scopes
|
||||
}
|
||||
|
|
|
@ -13,11 +13,11 @@ pub struct View {
|
|||
}
|
||||
|
||||
impl View {
|
||||
pub fn open(path: PathBuf, size: (u16, u16)) -> Result<View, Error> {
|
||||
pub fn open(path: PathBuf, size: (u16, u16)) -> Result<Self, Error> {
|
||||
let theme = Theme::default();
|
||||
let state = State::load(path, theme.scopes())?;
|
||||
|
||||
let view = View {
|
||||
let view = Self {
|
||||
state,
|
||||
first_line: 0,
|
||||
size, // TODO: pass in from term
|
||||
|
|
Loading…
Add table
Reference in a new issue