Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch statusline & prompt #5882

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions helix-term/src/ui/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,7 @@ impl EditorView {

Self::render_diagnostics(doc, view, inner, surface, theme);

let statusline_area = view
.area
.clip_top(view.area.height.saturating_sub(1))
.clip_bottom(1); // -1 from bottom to remove commandline
let statusline_area = view.area.clip_top(view.area.height);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This introduces the issue with split views. The easiest solution I could come up with was something like this:

// if we're not at the bottom of the screen, draw the statusline higher, otherwise
// it'll overlap with the next view
let statusline_area = if (viewport.bottom() - 1) == view.area.bottom() {
    view.area.clip_top(view.area.height)
} else {
    view.area
        .clip_top(view.area.height.saturating_sub(1))
        .clip_bottom(1)
};


let mut context =
statusline::RenderContext::new(editor, doc, view, is_focused, &self.spinners);
Expand Down Expand Up @@ -1388,7 +1385,7 @@ impl Component for EditorView {

surface.set_string(
area.x,
area.y + area.height.saturating_sub(1),
area.y + area.height.saturating_sub(2),
status_msg,
style,
);
Expand Down
6 changes: 3 additions & 3 deletions helix-term/src/ui/prompt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ impl Prompt {

let completion_area = Rect::new(
area.x,
(area.height - height).saturating_sub(1),
(area.height - height).saturating_sub(2),
area.width,
height,
);
Expand Down Expand Up @@ -447,7 +447,7 @@ impl Prompt {
text.render(inner, surface, cx);
}

let line = area.height - 1;
let line = area.height - 2;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This and the following change on line 642 break the file picker (and probably other prompts as well), since they can underflow.
If you substitute this and the change on line 642 with saturating_sub(2) this seems to fix it.

// render buffer text
surface.set_string(area.x, area.y + line, &self.prompt, prompt_color);

Expand Down Expand Up @@ -639,7 +639,7 @@ impl Component for Prompt {
}

fn cursor(&self, area: Rect, _editor: &Editor) -> (Option<Position>, CursorKind) {
let line = area.height as usize - 1;
let line = area.height as usize - 2;
(
Some(Position::new(
area.y as usize + line,
Expand Down