on master help sign in
Fix warnings from clippy (#7013)
3b8c156ZJPzjp
helix-core/src/surround.rs+1−6
@@ -397,15 +397,10 @@ mod test {
397
397
398 let selections: SmallVec<[Range; 1]> = spec
398 let selections: SmallVec<[Range; 1]> = spec
399 .match_indices('^')
399 .match_indices('^')
400− .into_iter()
401 .map(|(i, _)| Range::point(i))
400 .map(|(i, _)| Range::point(i))
402 .collect();
401 .collect();
403
402
404− let expectations: Vec<usize> = spec
403+ let expectations: Vec<usize> = spec.match_indices('_').map(|(i, _)| i).collect();
405− .match_indices('_')
406− .into_iter()
407− .map(|(i, _)| i)
408− .collect();
409
404
410 (rope, Selection::new(selections, 0), expectations)
405 (rope, Selection::new(selections, 0), expectations)
411 }
406 }
helix-core/src/syntax.rs+6−3
@@ -187,9 +187,12 @@ impl<'de> Deserialize<'de> for FileType {
187 M: serde::de::MapAccess<'de>,
187 M: serde::de::MapAccess<'de>,
188 {
188 {
189 match map.next_entry::<String, String>()? {
189 match map.next_entry::<String, String>()? {
190− Some((key, suffix)) if key == "suffix" => Ok(FileType::Suffix(
190+ Some((key, suffix)) if key == "suffix" => Ok(FileType::Suffix({
191+ // FIXME: use `suffix.replace('/', std::path::MAIN_SEPARATOR_STR)`
192+ // if MSRV is updated to 1.68
193+ let mut seperator = [0; 1];
191− suffix.replace('/', &std::path::MAIN_SEPARATOR.to_string()),
194+ suffix.replace('/', std::path::MAIN_SEPARATOR.encode_utf8(&mut seperator))
192− )),
195+ })),
193 Some((key, _value)) => Err(serde::de::Error::custom(format!(
196 Some((key, _value)) => Err(serde::de::Error::custom(format!(
194 "unknown key in `file-types` list: {}",
197 "unknown key in `file-types` list: {}",
195 key
198 key
helix-loader/src/lib.rs+18−18
@@ -209,6 +209,24 @@ pub fn merge_toml_values(left: toml::Value, right: toml::Value, merge_depth: usi
209 }
209 }
210}
210}
211
211
212+/// Finds the current workspace folder.
213+/// Used as a ceiling dir for LSP root resolution, the filepicker and potentially as a future filewatching root
214+///
215+/// This function starts searching the FS upward from the CWD
216+/// and returns the first directory that contains either `.git` or `.helix`.
217+/// If no workspace was found returns (CWD, true).
218+/// Otherwise (workspace, false) is returned
219+pub fn find_workspace() -> (PathBuf, bool) {
220+ let current_dir = std::env::current_dir().expect("unable to determine current directory");
221+ for ancestor in current_dir.ancestors() {
222+ if ancestor.join(".git").exists() || ancestor.join(".helix").exists() {
223+ return (ancestor.to_owned(), false);
224+ }
225+ }
226+
227+ (current_dir, true)
228+}
229+
212#[cfg(test)]
230#[cfg(test)]
213mod merge_toml_tests {
231mod merge_toml_tests {
214 use std::str;
232 use std::str;
@@ -281,21 +299,3 @@ mod merge_toml_tests {
281 )
299 )
282 }
300 }
283}
301}
284−
285−/// Finds the current workspace folder.
286−/// Used as a ceiling dir for LSP root resolution, the filepicker and potentially as a future filewatching root
287−///
288−/// This function starts searching the FS upward from the CWD
289−/// and returns the first directory that contains either `.git` or `.helix`.
290−/// If no workspace was found returns (CWD, true).
291−/// Otherwise (workspace, false) is returned
292−pub fn find_workspace() -> (PathBuf, bool) {
293− let current_dir = std::env::current_dir().expect("unable to determine current directory");
294− for ancestor in current_dir.ancestors() {
295− if ancestor.join(".git").exists() || ancestor.join(".helix").exists() {
296− return (ancestor.to_owned(), false);
297− }
298− }
299−
300− (current_dir, true)
301−}
helix-term/src/ui/editor.rs+1−1
@@ -103,7 +103,7 @@ impl EditorView {
103
103
104 // Set DAP highlights, if needed.
104 // Set DAP highlights, if needed.
105 if let Some(frame) = editor.current_stack_frame() {
105 if let Some(frame) = editor.current_stack_frame() {
106− let dap_line = frame.line.saturating_sub(1) as usize;
106+ let dap_line = frame.line.saturating_sub(1);
107 let style = theme.get("ui.highlight.frameline");
107 let style = theme.get("ui.highlight.frameline");
108 let line_decoration = move |renderer: &mut TextRenderer, pos: LinePos| {
108 let line_decoration = move |renderer: &mut TextRenderer, pos: LinePos| {
109 if pos.doc_line != dap_line {
109 if pos.doc_line != dap_line {
helix-tui/src/buffer.rs+1−1
@@ -442,7 +442,7 @@ impl Buffer {
442 let mut x_offset = x as usize;
442 let mut x_offset = x as usize;
443 let max_offset = min(self.area.right(), width.saturating_add(x));
443 let max_offset = min(self.area.right(), width.saturating_add(x));
444 let mut start_index = self.index_of(x, y);
444 let mut start_index = self.index_of(x, y);
445− let mut index = self.index_of(max_offset as u16, y);
445+ let mut index = self.index_of(max_offset, y);
446
446
447 let content_width = spans.width();
447 let content_width = spans.width();
448 let truncated = content_width > width as usize;
448 let truncated = content_width > width as usize;
helix-view/src/clipboard.rs+1−1
@@ -68,7 +68,7 @@ macro_rules! command_provider {
68
68
69#[cfg(windows)]
69#[cfg(windows)]
70pub fn get_clipboard_provider() -> Box<dyn ClipboardProvider> {
70pub fn get_clipboard_provider() -> Box<dyn ClipboardProvider> {
71− Box::new(provider::WindowsProvider::default())
71+ Box::<provider::WindowsProvider>::default()
72}
72}
73
73
74#[cfg(target_os = "macos")]
74#[cfg(target_os = "macos")]
helix-view/src/tree.rs+1−2
@@ -728,12 +728,11 @@ mod test {
728 tree.focus = l0;
728 tree.focus = l0;
729 let view = View::new(DocumentId::default(), GutterConfig::default());
729 let view = View::new(DocumentId::default(), GutterConfig::default());
730 tree.split(view, Layout::Vertical);
730 tree.split(view, Layout::Vertical);
731− let l2 = tree.focus;
732
731
733 // Tree in test
732 // Tree in test
734 // | L0 | L2 | |
733 // | L0 | L2 | |
735 // | L1 | R0 |
734 // | L1 | R0 |
736− tree.focus = l2;
735+ let l2 = tree.focus;
737 assert_eq!(Some(l0), tree.find_split_in_direction(l2, Direction::Left));
736 assert_eq!(Some(l0), tree.find_split_in_direction(l2, Direction::Left));
738 assert_eq!(Some(l1), tree.find_split_in_direction(l2, Direction::Down));
737 assert_eq!(Some(l1), tree.find_split_in_direction(l2, Direction::Down));
739 assert_eq!(Some(r0), tree.find_split_in_direction(l2, Direction::Right));
738 assert_eq!(Some(r0), tree.find_split_in_direction(l2, Direction::Right));