aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--helix-core/src/state.rs3
-rw-r--r--helix-core/src/syntax.rs14
-rw-r--r--helix-term/src/editor.rs7
-rw-r--r--helix-view/src/commands.rs14
-rw-r--r--helix-view/src/theme.rs1
-rw-r--r--helix-view/src/view.rs4
6 files changed, 21 insertions, 22 deletions
diff --git a/helix-core/src/state.rs b/helix-core/src/state.rs
index ffe88c3f..aa377091 100644
--- a/helix-core/src/state.rs
+++ b/helix-core/src/state.rs
@@ -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) {
diff --git a/helix-core/src/syntax.rs b/helix-core/src/syntax.rs
index 3d85ff25..638ec8ee 100644
--- a/helix-core/src/syntax.rs
+++ b/helix-core/src/syntax.rs
@@ -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
diff --git a/helix-term/src/editor.rs b/helix-term/src/editor.rs
index 131c285e..a3d6a04e 100644
--- a/helix-term/src/editor.rs
+++ b/helix-term/src/editor.rs
@@ -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
diff --git a/helix-view/src/commands.rs b/helix-view/src/commands.rs
index d611e4f6..bdfa57ec 100644
--- a/helix-view/src/commands.rs
+++ b/helix-view/src/commands.rs
@@ -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
diff --git a/helix-view/src/theme.rs b/helix-view/src/theme.rs
index d61457d7..4cc399ed 100644
--- a/helix-view/src/theme.rs
+++ b/helix-view/src/theme.rs
@@ -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
}
diff --git a/helix-view/src/view.rs b/helix-view/src/view.rs
index 0900b0ca..d96752d0 100644
--- a/helix-view/src/view.rs
+++ b/helix-view/src/view.rs
@@ -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