mirror of
https://github.com/helix-editor/helix.git
synced 2024-11-22 01:16:18 +04:00
style: format files
This commit is contained in:
parent
28e6509751
commit
26c22de1d0
@ -679,7 +679,7 @@ fn move_impl(cx: &mut Context, move_fn: MoveFn, dir: Direction, behaviour: Movem
|
||||
let config = cx.editor.config();
|
||||
let (view, doc) = current!(cx.editor);
|
||||
let unobtrusive_statusline = config.statusline.unobtrusive;
|
||||
|
||||
|
||||
let text = doc.text().slice(..);
|
||||
let text_fmt = doc.text_format(view.inner_area(doc, unobtrusive_statusline).width, None);
|
||||
let mut annotations = view.text_annotations(doc, None);
|
||||
@ -3106,7 +3106,11 @@ struct JumpMeta {
|
||||
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);
|
||||
|
@ -1803,7 +1803,7 @@ fn tutor(
|
||||
fn abort_goto_line_number_preview(cx: &mut compositor::Context) {
|
||||
if let Some(last_selection) = cx.editor.last_selection.take() {
|
||||
let config = cx.editor.config();
|
||||
|
||||
|
||||
let scrolloff = config.scrolloff;
|
||||
let unobtrusive_statusline = config.statusline.unobtrusive;
|
||||
|
||||
|
@ -104,7 +104,15 @@ pub fn render_view(
|
||||
}
|
||||
|
||||
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 @@ pub fn render_view(
|
||||
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 @@ fn handle_mouse_event(
|
||||
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 inserted_a_new_blank_line(changes: &[Operation], pos: usize, line_end_pos: us
|
||||
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;
|
||||
}
|
||||
|
@ -207,7 +207,7 @@ pub fn inner_height(&self, unobtrusive_statusline: bool) -> usize {
|
||||
self.area.clip_bottom(1).height.into() // -1 for statusline
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Does not account for height of statusline
|
||||
pub fn inner_area_raw(&self, doc: &Document) -> Rect {
|
||||
self.area.clip_left(self.gutter_offset(doc))
|
||||
@ -355,22 +355,42 @@ pub fn offset_coords_to_in_view_center<const CENTERING: bool>(
|
||||
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…
Reference in New Issue
Block a user