summaryrefslogtreecommitdiff
path: root/helix-term/src
diff options
context:
space:
mode:
authorBob2021-11-29 01:58:21 +0000
committerGitHub2021-11-29 01:58:21 +0000
commit42fde95223a62bded340a1737e8be50ef94af4af (patch)
tree76a4ea9a960ae7e08008a36c3a300ad20a1a2244 /helix-term/src
parent4f9390a435a44578bcedf1da63ea1fad92185afc (diff)
Accept count for goto_window (#1033)
* accept count for goto_window also fix view is not fullfilled issue * fix fulfilled mispell * Update helix-term/src/commands.rs Co-authored-by: Ivan Tham <pickfire@riseup.net> * Update helix-term/src/commands.rs Co-authored-by: Ivan Tham <pickfire@riseup.net> * fix merge issue * revert line computation logic Co-authored-by: Ivan Tham <pickfire@riseup.net>
Diffstat (limited to 'helix-term/src')
-rw-r--r--helix-term/src/commands.rs11
1 files changed, 7 insertions, 4 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index aafeb476..b4cc9ae9 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -733,10 +733,12 @@ fn align_fragment_to_width(fragment: &str, width: usize, align_style: usize) ->
}
fn goto_window(cx: &mut Context, align: Align) {
+ let count = cx.count() - 1;
let (view, doc) = current!(cx.editor);
let height = view.inner_area().height as usize;
+ // respect user given count if any
// - 1 so we have at least one gap in the middle.
// a height of 6 with padding of 3 on each side will keep shifting the view back and forth
// as we type
@@ -745,11 +747,12 @@ fn goto_window(cx: &mut Context, align: Align) {
let last_line = view.last_line(doc);
let line = match align {
- Align::Top => (view.offset.row + scrolloff),
- Align::Center => (view.offset.row + (height / 2)),
- Align::Bottom => last_line.saturating_sub(scrolloff),
+ Align::Top => (view.offset.row + scrolloff + count),
+ Align::Center => (view.offset.row + ((last_line - view.offset.row) / 2)),
+ Align::Bottom => last_line.saturating_sub(scrolloff + count),
}
- .min(last_line.saturating_sub(scrolloff));
+ .min(last_line.saturating_sub(scrolloff))
+ .max(view.offset.row + scrolloff);
let pos = doc.text().line_to_char(line);