mirror of
https://github.com/helix-editor/helix
synced 2024-06-13 08:56:07 +02:00
clippy warnings
This commit is contained in:
parent
1bb01d27ae
commit
3feb00283d
|
@ -358,7 +358,7 @@ fn skip_over_next<F>(slice: &RopeSlice, pos: &mut usize, fun: F)
|
||||||
{
|
{
|
||||||
let mut chars = slice.chars_at(*pos);
|
let mut chars = slice.chars_at(*pos);
|
||||||
|
|
||||||
while let Some(ch) = chars.next() {
|
for ch in chars {
|
||||||
if !fun(ch) {
|
if !fun(ch) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -372,7 +372,6 @@ fn skip_over_prev<F>(slice: &RopeSlice, pos: &mut usize, fun: F)
|
||||||
{
|
{
|
||||||
// need to +1 so that prev() includes current char
|
// 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);
|
||||||
let mut chars = slice.chars_at(*pos + 1);
|
|
||||||
|
|
||||||
while let Some(ch) = chars.prev() {
|
while let Some(ch) = chars.prev() {
|
||||||
if !fun(ch) {
|
if !fun(ch) {
|
||||||
|
|
|
@ -37,11 +37,11 @@ pub fn highlight_config(
|
||||||
|
|
||||||
let highlights_query =
|
let highlights_query =
|
||||||
std::fs::read_to_string(self.path.join("queries/highlights.scm"))
|
std::fs::read_to_string(self.path.join("queries/highlights.scm"))
|
||||||
.unwrap_or(String::new());
|
.unwrap_or_default();
|
||||||
|
|
||||||
let injections_query =
|
let injections_query =
|
||||||
std::fs::read_to_string(self.path.join("queries/injections.scm"))
|
std::fs::read_to_string(self.path.join("queries/injections.scm"))
|
||||||
.unwrap_or(String::new());
|
.unwrap_or_default();
|
||||||
|
|
||||||
let locals_query = "";
|
let locals_query = "";
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ pub fn highlight_config(
|
||||||
|
|
||||||
use once_cell::sync::Lazy;
|
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 {
|
pub struct Loader {
|
||||||
// highlight_names ?
|
// highlight_names ?
|
||||||
|
@ -159,7 +159,7 @@ pub fn new(
|
||||||
// let grammar = get_language(&language);
|
// let grammar = get_language(&language);
|
||||||
let parser = Parser::new();
|
let parser = Parser::new();
|
||||||
|
|
||||||
let root_layer = LanguageLayer::new();
|
let root_layer = LanguageLayer { tree: None };
|
||||||
|
|
||||||
// track markers of injections
|
// track markers of injections
|
||||||
// track scope_descriptor: a Vec of scopes for item in tree
|
// track scope_descriptor: a Vec of scopes for item in tree
|
||||||
|
@ -317,9 +317,9 @@ pub struct LanguageLayer {
|
||||||
use crate::Tendril;
|
use crate::Tendril;
|
||||||
|
|
||||||
impl LanguageLayer {
|
impl LanguageLayer {
|
||||||
pub fn new() -> Self {
|
// pub fn new() -> Self {
|
||||||
Self { tree: None }
|
// Self { tree: None }
|
||||||
}
|
// }
|
||||||
|
|
||||||
fn tree(&self) -> &Tree {
|
fn tree(&self) -> &Tree {
|
||||||
// TODO: no unwrap
|
// TODO: no unwrap
|
||||||
|
|
|
@ -209,12 +209,11 @@ fn render(&mut self) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut line = 0;
|
|
||||||
let style: Style = view.theme.get("ui.linenr").into();
|
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
|
self.surface
|
||||||
.set_stringn(0, line, format!("{:>5}", i + 1), 5, style); // lavender
|
.set_stringn(0, line, format!("{:>5}", i + 1), 5, style);
|
||||||
line += 1;
|
// lavender
|
||||||
}
|
}
|
||||||
|
|
||||||
// let lines = state
|
// let lines = state
|
||||||
|
|
|
@ -42,7 +42,7 @@ pub fn move_line_down(view: &mut View, count: usize) {
|
||||||
.move_selection(Direction::Forward, Granularity::Line, count);
|
.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
|
// TODO: use a transaction
|
||||||
let lines = selection_lines(&view.state);
|
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);
|
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 lines = selection_lines(&view.state);
|
||||||
|
|
||||||
let positions = lines
|
let positions = lines
|
||||||
|
@ -208,24 +208,24 @@ fn selection_lines(state: &State) -> Vec<usize> {
|
||||||
.map(|range| state.doc.char_to_line(range.head))
|
.map(|range| state.doc.char_to_line(range.head))
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
lines.sort();
|
lines.sort_unstable(); // sorting by usize so _unstable is preferred
|
||||||
lines.dedup();
|
lines.dedup();
|
||||||
|
|
||||||
lines
|
lines
|
||||||
}
|
}
|
||||||
|
|
||||||
// I inserts at the start of each line with a selection
|
// 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;
|
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
|
// 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;
|
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
|
// o inserts a new line after each line with a selection
|
||||||
|
|
|
@ -173,6 +173,7 @@ pub fn get(&self, scope: &str) -> Style {
|
||||||
.unwrap_or_else(|| Style::default().fg(Color::Rgb(0, 0, 255)))
|
.unwrap_or_else(|| Style::default().fg(Color::Rgb(0, 0, 255)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn scopes(&self) -> &[String] {
|
pub fn scopes(&self) -> &[String] {
|
||||||
&self.scopes
|
&self.scopes
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,11 +13,11 @@ pub struct View {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl 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 theme = Theme::default();
|
||||||
let state = State::load(path, theme.scopes())?;
|
let state = State::load(path, theme.scopes())?;
|
||||||
|
|
||||||
let view = View {
|
let view = Self {
|
||||||
state,
|
state,
|
||||||
first_line: 0,
|
first_line: 0,
|
||||||
size, // TODO: pass in from term
|
size, // TODO: pass in from term
|
||||||
|
|
Loading…
Reference in New Issue