aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--helix-core/src/surround.rs7
-rw-r--r--helix-core/src/syntax.rs9
-rw-r--r--helix-loader/src/lib.rs36
-rw-r--r--helix-term/src/ui/editor.rs2
-rw-r--r--helix-tui/src/buffer.rs2
-rw-r--r--helix-view/src/clipboard.rs2
-rw-r--r--helix-view/src/tree.rs3
7 files changed, 29 insertions, 32 deletions
diff --git a/helix-core/src/surround.rs b/helix-core/src/surround.rs
index f430aee8..b96cce5a 100644
--- a/helix-core/src/surround.rs
+++ b/helix-core/src/surround.rs
@@ -397,15 +397,10 @@ mod test {
let selections: SmallVec<[Range; 1]> = spec
.match_indices('^')
- .into_iter()
.map(|(i, _)| Range::point(i))
.collect();
- let expectations: Vec<usize> = spec
- .match_indices('_')
- .into_iter()
- .map(|(i, _)| i)
- .collect();
+ let expectations: Vec<usize> = spec.match_indices('_').map(|(i, _)| i).collect();
(rope, Selection::new(selections, 0), expectations)
}
diff --git a/helix-core/src/syntax.rs b/helix-core/src/syntax.rs
index 6514b40f..005e985d 100644
--- a/helix-core/src/syntax.rs
+++ b/helix-core/src/syntax.rs
@@ -187,9 +187,12 @@ impl<'de> Deserialize<'de> for FileType {
M: serde::de::MapAccess<'de>,
{
match map.next_entry::<String, String>()? {
- Some((key, suffix)) if key == "suffix" => Ok(FileType::Suffix(
- suffix.replace('/', &std::path::MAIN_SEPARATOR.to_string()),
- )),
+ Some((key, suffix)) if key == "suffix" => Ok(FileType::Suffix({
+ // FIXME: use `suffix.replace('/', std::path::MAIN_SEPARATOR_STR)`
+ // if MSRV is updated to 1.68
+ let mut seperator = [0; 1];
+ suffix.replace('/', std::path::MAIN_SEPARATOR.encode_utf8(&mut seperator))
+ })),
Some((key, _value)) => Err(serde::de::Error::custom(format!(
"unknown key in `file-types` list: {}",
key
diff --git a/helix-loader/src/lib.rs b/helix-loader/src/lib.rs
index 6c716975..ad4ad899 100644
--- a/helix-loader/src/lib.rs
+++ b/helix-loader/src/lib.rs
@@ -209,6 +209,24 @@ pub fn merge_toml_values(left: toml::Value, right: toml::Value, merge_depth: usi
}
}
+/// Finds the current workspace folder.
+/// Used as a ceiling dir for LSP root resolution, the filepicker and potentially as a future filewatching root
+///
+/// This function starts searching the FS upward from the CWD
+/// and returns the first directory that contains either `.git` or `.helix`.
+/// If no workspace was found returns (CWD, true).
+/// Otherwise (workspace, false) is returned
+pub fn find_workspace() -> (PathBuf, bool) {
+ let current_dir = std::env::current_dir().expect("unable to determine current directory");
+ for ancestor in current_dir.ancestors() {
+ if ancestor.join(".git").exists() || ancestor.join(".helix").exists() {
+ return (ancestor.to_owned(), false);
+ }
+ }
+
+ (current_dir, true)
+}
+
#[cfg(test)]
mod merge_toml_tests {
use std::str;
@@ -281,21 +299,3 @@ mod merge_toml_tests {
)
}
}
-
-/// Finds the current workspace folder.
-/// Used as a ceiling dir for LSP root resolution, the filepicker and potentially as a future filewatching root
-///
-/// This function starts searching the FS upward from the CWD
-/// and returns the first directory that contains either `.git` or `.helix`.
-/// If no workspace was found returns (CWD, true).
-/// Otherwise (workspace, false) is returned
-pub fn find_workspace() -> (PathBuf, bool) {
- let current_dir = std::env::current_dir().expect("unable to determine current directory");
- for ancestor in current_dir.ancestors() {
- if ancestor.join(".git").exists() || ancestor.join(".helix").exists() {
- return (ancestor.to_owned(), false);
- }
- }
-
- (current_dir, true)
-}
diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs
index fd8e8fb2..1ecbc8cc 100644
--- a/helix-term/src/ui/editor.rs
+++ b/helix-term/src/ui/editor.rs
@@ -103,7 +103,7 @@ impl EditorView {
// Set DAP highlights, if needed.
if let Some(frame) = editor.current_stack_frame() {
- let dap_line = frame.line.saturating_sub(1) as usize;
+ let dap_line = frame.line.saturating_sub(1);
let style = theme.get("ui.highlight.frameline");
let line_decoration = move |renderer: &mut TextRenderer, pos: LinePos| {
if pos.doc_line != dap_line {
diff --git a/helix-tui/src/buffer.rs b/helix-tui/src/buffer.rs
index 8e0b0adf..93e9fcf9 100644
--- a/helix-tui/src/buffer.rs
+++ b/helix-tui/src/buffer.rs
@@ -442,7 +442,7 @@ impl Buffer {
let mut x_offset = x as usize;
let max_offset = min(self.area.right(), width.saturating_add(x));
let mut start_index = self.index_of(x, y);
- let mut index = self.index_of(max_offset as u16, y);
+ let mut index = self.index_of(max_offset, y);
let content_width = spans.width();
let truncated = content_width > width as usize;
diff --git a/helix-view/src/clipboard.rs b/helix-view/src/clipboard.rs
index d43d632a..d639902f 100644
--- a/helix-view/src/clipboard.rs
+++ b/helix-view/src/clipboard.rs
@@ -68,7 +68,7 @@ macro_rules! command_provider {
#[cfg(windows)]
pub fn get_clipboard_provider() -> Box<dyn ClipboardProvider> {
- Box::new(provider::WindowsProvider::default())
+ Box::<provider::WindowsProvider>::default()
}
#[cfg(target_os = "macos")]
diff --git a/helix-view/src/tree.rs b/helix-view/src/tree.rs
index e8afd204..4c9eba0f 100644
--- a/helix-view/src/tree.rs
+++ b/helix-view/src/tree.rs
@@ -728,12 +728,11 @@ mod test {
tree.focus = l0;
let view = View::new(DocumentId::default(), GutterConfig::default());
tree.split(view, Layout::Vertical);
- let l2 = tree.focus;
// Tree in test
// | L0 | L2 | |
// | L1 | R0 |
- tree.focus = l2;
+ let l2 = tree.focus;
assert_eq!(Some(l0), tree.find_split_in_direction(l2, Direction::Left));
assert_eq!(Some(l1), tree.find_split_in_direction(l2, Direction::Down));
assert_eq!(Some(r0), tree.find_split_in_direction(l2, Direction::Right));