mirror of https://github.com/lapce/lapce.git
Minor cleanups (#1235)
* Clean up manual min impl * Only clone if necessary
This commit is contained in:
parent
07390f0c90
commit
f73b4d961f
|
@ -53,10 +53,7 @@ pub fn line_of_height(&self, height: usize) -> usize {
|
|||
}
|
||||
|
||||
pub fn height_of_line(&self, line: usize) -> usize {
|
||||
let max_line = self.0.len();
|
||||
if line >= max_line {
|
||||
return self.0.count::<LensMetric>(self.0.len());
|
||||
}
|
||||
let line = self.0.len().min(line);
|
||||
self.0.count::<LensMetric>(line)
|
||||
}
|
||||
|
||||
|
|
|
@ -905,7 +905,7 @@ fn next_diff(&mut self, ctx: &mut EventCtx) {
|
|||
let (path, offset) =
|
||||
next_in_file_diff_offset(offset, buffer_path, &diff_files);
|
||||
let location = EditorLocation {
|
||||
path,
|
||||
path: path.to_path_buf(),
|
||||
position: Some(offset),
|
||||
scroll_offset: None,
|
||||
history: Some("head".to_string()),
|
||||
|
@ -2433,24 +2433,24 @@ pub struct HighlightTextLayout {
|
|||
pub highlights: Vec<(usize, usize, String)>,
|
||||
}
|
||||
|
||||
fn next_in_file_diff_offset(
|
||||
fn next_in_file_diff_offset<'a>(
|
||||
offset: usize,
|
||||
path: &Path,
|
||||
file_diffs: &[(PathBuf, Vec<usize>)],
|
||||
) -> (PathBuf, usize) {
|
||||
file_diffs: &'a [(PathBuf, Vec<usize>)],
|
||||
) -> (&'a Path, usize) {
|
||||
for (current_path, offsets) in file_diffs {
|
||||
if path == current_path {
|
||||
for diff_offset in offsets {
|
||||
if *diff_offset > offset {
|
||||
return ((*current_path).clone(), *diff_offset);
|
||||
return (current_path.as_ref(), *diff_offset);
|
||||
}
|
||||
}
|
||||
}
|
||||
if current_path > path {
|
||||
return ((*current_path).clone(), offsets[0]);
|
||||
return (current_path.as_ref(), offsets[0]);
|
||||
}
|
||||
}
|
||||
((file_diffs[0].0).clone(), file_diffs[0].1[0])
|
||||
(file_diffs[0].0.as_ref(), file_diffs[0].1[0])
|
||||
}
|
||||
|
||||
fn next_in_file_errors_offset(
|
||||
|
|
Loading…
Reference in New Issue