mirror of https://github.com/helix-editor/helix
Remove #[allow(unused)] from helix-core, and fix unused imports.
Still a bunch more warnings to fix in core, but it's a start.pull/400/head
parent
0b2d51cf5a
commit
b571f28641
|
@ -1,7 +1,6 @@
|
||||||
use crate::{ChangeSet, Rope, State, Transaction};
|
use crate::{ChangeSet, Rope, State, Transaction};
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use smallvec::{smallvec, SmallVec};
|
|
||||||
use std::num::NonZeroUsize;
|
use std::num::NonZeroUsize;
|
||||||
use std::time::{Duration, Instant};
|
use std::time::{Duration, Instant};
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
find_first_non_whitespace_char,
|
find_first_non_whitespace_char,
|
||||||
syntax::{IndentQuery, LanguageConfiguration, Syntax},
|
syntax::{IndentQuery, LanguageConfiguration, Syntax},
|
||||||
tree_sitter::{Node, Tree},
|
tree_sitter::Node,
|
||||||
Rope, RopeSlice,
|
RopeSlice,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// To determine indentation of a newly inserted line, figure out the indentation at the last col
|
/// To determine indentation of a newly inserted line, figure out the indentation at the last col
|
||||||
|
@ -150,6 +150,7 @@ pub fn suggested_indent_for_pos(
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
use crate::Rope;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_indent_level() {
|
fn test_indent_level() {
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
#![allow(unused)]
|
|
||||||
pub mod auto_pairs;
|
pub mod auto_pairs;
|
||||||
pub mod chars;
|
pub mod chars;
|
||||||
pub mod comment;
|
pub mod comment;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::{Rope, RopeGraphemes, RopeSlice};
|
use crate::{Rope, RopeSlice};
|
||||||
|
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
pub const DEFAULT_LINE_ENDING: LineEnding = LineEnding::Crlf;
|
pub const DEFAULT_LINE_ENDING: LineEnding = LineEnding::Crlf;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::{Range, Rope, Selection, Syntax};
|
use crate::{Rope, Syntax};
|
||||||
|
|
||||||
const PAIRS: &[(char, char)] = &[('(', ')'), ('{', '}'), ('[', ']'), ('<', '>')];
|
const PAIRS: &[(char, char)] = &[('(', ')'), ('{', '}'), ('[', ']'), ('<', '>')];
|
||||||
// limit matching pairs to only ( ) { } [ ] < >
|
// limit matching pairs to only ( ) { } [ ] < >
|
||||||
|
|
|
@ -1,12 +1,9 @@
|
||||||
use std::iter::{self, from_fn, Peekable, SkipWhile};
|
use std::iter::{self, from_fn};
|
||||||
|
|
||||||
use ropey::iter::Chars;
|
use ropey::iter::Chars;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
chars::{
|
chars::{categorize_char, char_is_line_ending, CharCategory},
|
||||||
categorize_char, char_is_line_ending, char_is_punctuation, char_is_whitespace,
|
|
||||||
char_is_word, CharCategory,
|
|
||||||
},
|
|
||||||
coords_at_pos,
|
coords_at_pos,
|
||||||
graphemes::{nth_next_grapheme_boundary, nth_prev_grapheme_boundary},
|
graphemes::{nth_next_grapheme_boundary, nth_prev_grapheme_boundary},
|
||||||
line_ending::{get_line_ending, line_end_char_index},
|
line_ending::{get_line_ending, line_end_char_index},
|
||||||
|
@ -270,20 +267,20 @@ fn reached_target(target: WordMotionTarget, peek: char, next_peek: Option<&char>
|
||||||
|
|
||||||
match target {
|
match target {
|
||||||
WordMotionTarget::NextWordStart => {
|
WordMotionTarget::NextWordStart => {
|
||||||
(is_word_boundary(peek, *next_peek)
|
is_word_boundary(peek, *next_peek)
|
||||||
&& (char_is_line_ending(*next_peek) || !next_peek.is_whitespace()))
|
&& (char_is_line_ending(*next_peek) || !next_peek.is_whitespace())
|
||||||
}
|
}
|
||||||
WordMotionTarget::NextWordEnd | WordMotionTarget::PrevWordStart => {
|
WordMotionTarget::NextWordEnd | WordMotionTarget::PrevWordStart => {
|
||||||
(is_word_boundary(peek, *next_peek)
|
is_word_boundary(peek, *next_peek)
|
||||||
&& (!peek.is_whitespace() || char_is_line_ending(*next_peek)))
|
&& (!peek.is_whitespace() || char_is_line_ending(*next_peek))
|
||||||
}
|
}
|
||||||
WordMotionTarget::NextLongWordStart => {
|
WordMotionTarget::NextLongWordStart => {
|
||||||
(is_long_word_boundary(peek, *next_peek)
|
is_long_word_boundary(peek, *next_peek)
|
||||||
&& (char_is_line_ending(*next_peek) || !next_peek.is_whitespace()))
|
&& (char_is_line_ending(*next_peek) || !next_peek.is_whitespace())
|
||||||
}
|
}
|
||||||
WordMotionTarget::NextLongWordEnd | WordMotionTarget::PrevLongWordStart => {
|
WordMotionTarget::NextLongWordEnd | WordMotionTarget::PrevLongWordStart => {
|
||||||
(is_long_word_boundary(peek, *next_peek)
|
is_long_word_boundary(peek, *next_peek)
|
||||||
&& (!peek.is_whitespace() || char_is_line_ending(*next_peek)))
|
&& (!peek.is_whitespace() || char_is_line_ending(*next_peek))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
use crate::{Range, RopeSlice, Selection, Syntax};
|
use crate::{Range, RopeSlice, Selection, Syntax};
|
||||||
use smallvec::smallvec;
|
|
||||||
|
|
||||||
// TODO: to contract_selection we'd need to store the previous ranges before expand.
|
// TODO: to contract_selection we'd need to store the previous ranges before expand.
|
||||||
// Maybe just contract to the first child node?
|
// Maybe just contract to the first child node?
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
chars::char_is_line_ending,
|
chars::char_is_line_ending,
|
||||||
graphemes::{nth_next_grapheme_boundary, RopeGraphemes},
|
graphemes::{nth_next_grapheme_boundary, RopeGraphemes},
|
||||||
Rope, RopeSlice,
|
RopeSlice,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Represents a single point in a text buffer. Zero indexed.
|
/// Represents a single point in a text buffer. Zero indexed.
|
||||||
|
@ -70,6 +70,7 @@ pub fn pos_at_coords(text: RopeSlice, coords: Position) -> usize {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
use crate::Rope;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_ordering() {
|
fn test_ordering() {
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
//! single selection range.
|
//! single selection range.
|
||||||
//!
|
//!
|
||||||
//! All positioning is done via `char` offsets into the buffer.
|
//! All positioning is done via `char` offsets into the buffer.
|
||||||
use crate::{Assoc, ChangeSet, Rope, RopeSlice};
|
use crate::{Assoc, ChangeSet, RopeSlice};
|
||||||
use smallvec::{smallvec, SmallVec};
|
use smallvec::{smallvec, SmallVec};
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
|
||||||
|
@ -406,6 +406,7 @@ pub fn split_on_matches(
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
use crate::Rope;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[should_panic]
|
#[should_panic]
|
||||||
|
|
|
@ -1,4 +1,10 @@
|
||||||
use crate::{chars::char_is_line_ending, regex::Regex, Change, Rope, RopeSlice, Transaction};
|
use crate::{
|
||||||
|
chars::char_is_line_ending,
|
||||||
|
regex::Regex,
|
||||||
|
transaction::{ChangeSet, Operation},
|
||||||
|
Rope, RopeSlice, Tendril,
|
||||||
|
};
|
||||||
|
|
||||||
pub use helix_syntax::{get_language, get_language_name, Lang};
|
pub use helix_syntax::{get_language, get_language_name, Lang};
|
||||||
|
|
||||||
use arc_swap::ArcSwap;
|
use arc_swap::ArcSwap;
|
||||||
|
@ -8,7 +14,7 @@ use std::{
|
||||||
cell::RefCell,
|
cell::RefCell,
|
||||||
collections::{HashMap, HashSet},
|
collections::{HashMap, HashSet},
|
||||||
fmt,
|
fmt,
|
||||||
path::{Path, PathBuf},
|
path::Path,
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -473,12 +479,6 @@ pub struct LanguageLayer {
|
||||||
pub(crate) tree: Option<Tree>,
|
pub(crate) tree: Option<Tree>,
|
||||||
}
|
}
|
||||||
|
|
||||||
use crate::{
|
|
||||||
coords_at_pos,
|
|
||||||
transaction::{ChangeSet, Operation},
|
|
||||||
Tendril,
|
|
||||||
};
|
|
||||||
|
|
||||||
impl LanguageLayer {
|
impl LanguageLayer {
|
||||||
// pub fn new() -> Self {
|
// pub fn new() -> Self {
|
||||||
// Self { tree: None }
|
// Self { tree: None }
|
||||||
|
@ -1776,8 +1776,13 @@ impl<I: Iterator<Item = HighlightEvent>> Iterator for Merge<I> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[cfg(test)]
|
||||||
fn test_parser() {
|
mod test {
|
||||||
|
use super::*;
|
||||||
|
use crate::{Rope, Transaction};
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_parser() {
|
||||||
let highlight_names: Vec<String> = [
|
let highlight_names: Vec<String> = [
|
||||||
"attribute",
|
"attribute",
|
||||||
"constant",
|
"constant",
|
||||||
|
@ -1841,10 +1846,10 @@ fn test_parser() {
|
||||||
|
|
||||||
let struct_node = root.child(0).unwrap();
|
let struct_node = root.child(0).unwrap();
|
||||||
assert_eq!(struct_node.kind(), "struct_item");
|
assert_eq!(struct_node.kind(), "struct_item");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_input_edits() {
|
fn test_input_edits() {
|
||||||
use crate::State;
|
use crate::State;
|
||||||
use tree_sitter::InputEdit;
|
use tree_sitter::InputEdit;
|
||||||
|
|
||||||
|
@ -1897,14 +1902,15 @@ fn test_input_edits() {
|
||||||
new_end_position: Point { row: 0, column: 14 }
|
new_end_position: Point { row: 0, column: 14 }
|
||||||
}]
|
}]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_load_runtime_file() {
|
fn test_load_runtime_file() {
|
||||||
// Test to make sure we can load some data from the runtime directory.
|
// Test to make sure we can load some data from the runtime directory.
|
||||||
let contents = load_runtime_file("rust", "indents.toml").unwrap();
|
let contents = load_runtime_file("rust", "indents.toml").unwrap();
|
||||||
assert!(!contents.is_empty());
|
assert!(!contents.is_empty());
|
||||||
|
|
||||||
let results = load_runtime_file("rust", "does-not-exist");
|
let results = load_runtime_file("rust", "does-not-exist");
|
||||||
assert!(results.is_err());
|
assert!(results.is_err());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use crate::{Range, Rope, Selection, State, Tendril};
|
use crate::{Range, Rope, Selection, Tendril};
|
||||||
use std::{borrow::Cow, convert::TryFrom};
|
use std::borrow::Cow;
|
||||||
|
|
||||||
/// (from, to, replacement)
|
/// (from, to, replacement)
|
||||||
pub type Change = (usize, usize, Option<Tendril>);
|
pub type Change = (usize, usize, Option<Tendril>);
|
||||||
|
@ -581,6 +581,7 @@ impl<'a> Iterator for ChangeIterator<'a> {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
use crate::State;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn composition() {
|
fn composition() {
|
||||||
|
|
Loading…
Reference in New Issue