refactor: move inlay hints computation function earlier
This commit is contained in:
parent
0ce04ea455
commit
0c50ce1432
1 changed files with 18 additions and 18 deletions
|
@ -1254,6 +1254,24 @@ pub fn compute_inlay_hints_for_all_views(editor: &mut Editor, jobs: &mut crate::
|
|||
}
|
||||
}
|
||||
|
||||
fn compute_lines(view: &View, doc: &Document) -> (usize, usize) {
|
||||
// Compute ~3 times the current view height of color swatches, that way some scrolling
|
||||
// will not show half the view with hints and half without while still being faster
|
||||
// than computing all the hints for the full file (which could be dozens of time
|
||||
// longer than the view is).
|
||||
let doc_text = doc.text();
|
||||
let len_lines = doc_text.len_lines();
|
||||
|
||||
let view_height = view.inner_height();
|
||||
let first_visible_line =
|
||||
doc_text.char_to_line(doc.view_offset(view.id).anchor.min(doc_text.len_chars()));
|
||||
let first_line = first_visible_line.saturating_sub(view_height);
|
||||
let last_line = first_visible_line
|
||||
.saturating_add(view_height.saturating_mul(2))
|
||||
.min(len_lines);
|
||||
(first_line, last_line)
|
||||
}
|
||||
|
||||
fn compute_inlay_hints_for_view(
|
||||
view: &View,
|
||||
doc: &Document,
|
||||
|
@ -1403,24 +1421,6 @@ pub fn compute_color_swatches_for_all_views(editor: &mut Editor, jobs: &mut crat
|
|||
}
|
||||
}
|
||||
|
||||
fn compute_lines(view: &View, doc: &Document) -> (usize, usize) {
|
||||
// Compute ~3 times the current view height of color swatches, that way some scrolling
|
||||
// will not show half the view with hints and half without while still being faster
|
||||
// than computing all the hints for the full file (which could be dozens of time
|
||||
// longer than the view is).
|
||||
let doc_text = doc.text();
|
||||
let len_lines = doc_text.len_lines();
|
||||
|
||||
let view_height = view.inner_height();
|
||||
let first_visible_line =
|
||||
doc_text.char_to_line(doc.view_offset(view.id).anchor.min(doc_text.len_chars()));
|
||||
let first_line = first_visible_line.saturating_sub(view_height);
|
||||
let last_line = first_visible_line
|
||||
.saturating_add(view_height.saturating_mul(2))
|
||||
.min(len_lines);
|
||||
(first_line, last_line)
|
||||
}
|
||||
|
||||
fn compute_color_swatches_for_view(
|
||||
view: &View,
|
||||
doc: &Document,
|
||||
|
|
Loading…
Reference in a new issue