Refactor TextLayoutDetails construction
This commit is contained in:
parent
138fa45ecb
commit
3eb8aa8085
10 changed files with 52 additions and 64 deletions
|
@ -1,6 +1,6 @@
|
|||
use super::{Bias, DisplayPoint, DisplaySnapshot, SelectionGoal, ToDisplayPoint};
|
||||
use crate::{char_kind, CharKind, Editor, EditorStyle, ToOffset, ToPoint};
|
||||
use gpui::{FontCache, TextLayoutCache, WindowContext};
|
||||
use crate::{char_kind, CharKind, EditorStyle, ToOffset, ToPoint};
|
||||
use gpui::{FontCache, TextLayoutCache};
|
||||
use language::Point;
|
||||
use std::{ops::Range, sync::Arc};
|
||||
|
||||
|
@ -18,16 +18,6 @@ pub struct TextLayoutDetails {
|
|||
pub editor_style: EditorStyle,
|
||||
}
|
||||
|
||||
impl TextLayoutDetails {
|
||||
pub fn new(editor: &Editor, cx: &WindowContext) -> TextLayoutDetails {
|
||||
TextLayoutDetails {
|
||||
font_cache: cx.font_cache().clone(),
|
||||
text_layout_cache: cx.text_layout_cache().clone(),
|
||||
editor_style: editor.style(cx),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn left(map: &DisplaySnapshot, mut point: DisplayPoint) -> DisplayPoint {
|
||||
if point.column() > 0 {
|
||||
*point.column_mut() -= 1;
|
||||
|
@ -743,7 +733,7 @@ mod tests {
|
|||
let window = cx.window.clone();
|
||||
cx.update_window(window, |cx| {
|
||||
let text_layout_details =
|
||||
editor.read_with(cx, |editor, cx| TextLayoutDetails::new(editor, cx));
|
||||
editor.read_with(cx, |editor, cx| editor.text_layout_details(cx));
|
||||
|
||||
let family_id = cx
|
||||
.font_cache()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue