style: format files

pull/12020/head
Nikita Revenco 2 weeks ago
parent 28e6509751
commit 26c22de1d0

@ -3106,7 +3106,11 @@ fn jumplist_picker(cx: &mut Context) {
let (view, doc) = (view_mut!(cx.editor), doc_mut!(cx.editor, &meta.id));
doc.set_selection(view.id, meta.selection.clone());
if action.align_view(view, doc.id()) {
view.ensure_cursor_in_view_center(doc, config.scrolloff, config.statusline.unobtrusive);
view.ensure_cursor_in_view_center(
doc,
config.scrolloff,
config.statusline.unobtrusive,
);
}
},
)
@ -3282,7 +3286,11 @@ pub fn command_palette(cx: &mut Context) {
let view = view_mut!(ctx.editor, focus);
let doc = doc_mut!(ctx.editor, &view.doc);
view.ensure_cursor_in_view(doc, config.scrolloff, config.statusline.unobtrusive);
view.ensure_cursor_in_view(
doc,
config.scrolloff,
config.statusline.unobtrusive,
);
if mode != Mode::Insert {
doc.append_changes_to_history(view);

@ -104,7 +104,15 @@ impl EditorView {
}
if is_focused && config.cursorcolumn {
Self::highlight_cursorcolumn(doc, view, surface, theme, inner, &text_annotations, config.statusline.unobtrusive);
Self::highlight_cursorcolumn(
doc,
view,
surface,
theme,
inner,
&text_annotations,
config.statusline.unobtrusive,
);
}
// Set DAP highlights, if needed.
@ -241,7 +249,12 @@ impl EditorView {
let mut context =
statusline::RenderContext::new(editor, doc, view, is_focused, &self.spinners);
statusline::render(&mut context, statusline_area, surface, unobtrusive_statusline);
statusline::render(
&mut context,
statusline_area,
surface,
unobtrusive_statusline,
);
}
pub fn render_rulers(
@ -1196,7 +1209,13 @@ impl EditorView {
MouseEventKind::Drag(MouseButton::Left) => {
let (view, doc) = current!(cxt.editor);
let pos = match view.pos_at_screen_coords(doc, row, column, true, config.statusline.unobtrusive) {
let pos = match view.pos_at_screen_coords(
doc,
row,
column,
true,
config.statusline.unobtrusive,
) {
Some(pos) => pos,
None => return EventResult::Ignored(None),
};

@ -131,7 +131,11 @@ pub fn raw_regex_prompt(
fun(cx, regex, input, event);
let (view, doc) = current!(cx.editor);
view.ensure_cursor_in_view(doc, config.scrolloff, config.statusline.unobtrusive);
view.ensure_cursor_in_view(
doc,
config.scrolloff,
config.statusline.unobtrusive,
);
}
Err(err) => {
let (view, doc) = current!(cx.editor);

@ -49,7 +49,12 @@ pub struct RenderBuffer<'a> {
pub right: Spans<'a>,
}
pub fn render(context: &mut RenderContext, viewport: Rect, surface: &mut Surface, unobtrusive_statusline: bool) {
pub fn render(
context: &mut RenderContext,
viewport: Rect,
surface: &mut Surface,
unobtrusive_statusline: bool,
) {
let base_style = if context.focused {
context.editor.theme.get("ui.statusline")
} else {
@ -59,7 +64,7 @@ pub fn render(context: &mut RenderContext, viewport: Rect, surface: &mut Surface
let surface_style = if unobtrusive_statusline {
let surface_bg = match base_style.bg {
Some(color) => color,
None => helix_view::theme::Color::Reset
None => helix_view::theme::Color::Reset,
};
Style::default().bg(surface_bg)
} else {

@ -2210,7 +2210,12 @@ fn try_restore_indent(doc: &mut Document, view: &mut View) {
pub struct CursorCache(Cell<Option<Option<Position>>>);
impl CursorCache {
pub fn get(&self, view: &View, doc: &Document, unobtrusive_statusline: bool) -> Option<Position> {
pub fn get(
&self,
view: &View,
doc: &Document,
unobtrusive_statusline: bool,
) -> Option<Position> {
if let Some(pos) = self.0.get() {
return pos;
}

@ -355,22 +355,42 @@ impl View {
Some(offset)
}
pub fn ensure_cursor_in_view(&self, doc: &mut Document, scrolloff: usize, unobtrusive_statusline: bool) {
if let Some(offset) = self.offset_coords_to_in_view_center::<false>(doc, scrolloff, unobtrusive_statusline) {
pub fn ensure_cursor_in_view(
&self,
doc: &mut Document,
scrolloff: usize,
unobtrusive_statusline: bool,
) {
if let Some(offset) =
self.offset_coords_to_in_view_center::<false>(doc, scrolloff, unobtrusive_statusline)
{
doc.set_view_offset(self.id, offset);
}
}
pub fn ensure_cursor_in_view_center(&self, doc: &mut Document, scrolloff: usize, unobtrusive_statusline: bool) {
if let Some(offset) = self.offset_coords_to_in_view_center::<true>(doc, scrolloff, unobtrusive_statusline) {
pub fn ensure_cursor_in_view_center(
&self,
doc: &mut Document,
scrolloff: usize,
unobtrusive_statusline: bool,
) {
if let Some(offset) =
self.offset_coords_to_in_view_center::<true>(doc, scrolloff, unobtrusive_statusline)
{
doc.set_view_offset(self.id, offset);
} else {
align_view(doc, self, Align::Center, unobtrusive_statusline);
}
}
pub fn is_cursor_in_view(&mut self, doc: &Document, scrolloff: usize, unobtrusive_statusline: bool) -> bool {
self.offset_coords_to_in_view(doc, scrolloff, unobtrusive_statusline).is_none()
pub fn is_cursor_in_view(
&mut self,
doc: &Document,
scrolloff: usize,
unobtrusive_statusline: bool,
) -> bool {
self.offset_coords_to_in_view(doc, scrolloff, unobtrusive_statusline)
.is_none()
}
/// Estimates the last visible document line on screen.

Loading…
Cancel
Save