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

extend_line_above ignores count #3416

Closed
dead10ck opened this issue Aug 13, 2022 · 1 comment · Fixed by #3046
Closed

extend_line_above ignores count #3416

dead10ck opened this issue Aug 13, 2022 · 1 comment · Fixed by #3046
Labels
A-helix-term Area: Helix term improvements C-bug Category: This is a bug

Comments

@dead10ck
Copy link
Member

It looks like when extend_line_above is selecting the new line range, it takes the count into account for extending below, but above just hardcodes subtracting 1.

fn extend_line_impl(cx: &mut Context, extend: Extend) {
let count = cx.count();
let (view, doc) = current!(cx.editor);
let text = doc.text();
let selection = doc.selection(view.id).clone().transform(|range| {
let (start_line, end_line) = range.line_range(text.slice(..));
let start = text.line_to_char(start_line);
let end = text.line_to_char((end_line + count).min(text.len_lines()));
// extend to previous/next line if current line is selected
let (anchor, head) = if range.from() == start && range.to() == end {
match extend {
Extend::Above => (end, text.line_to_char(start_line.saturating_sub(1))),
Extend::Below => (
start,
text.line_to_char((end_line + count + 1).min(text.len_lines())),
),
}
} else {
(start, end)
};
Range::new(anchor, head)
});
doc.set_selection(view.id, selection);
}

@the-mikedavis the-mikedavis added C-bug Category: This is a bug A-helix-term Area: Helix term improvements labels Aug 13, 2022
@QiBaobin
Copy link
Contributor

QiBaobin commented Aug 15, 2022

I fixed it in the #3046 : https://github.com/helix-editor/helix/pull/3046/files , if need, I separated this part to another PR.

@the-mikedavis the-mikedavis linked a pull request Aug 15, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-helix-term Area: Helix term improvements C-bug Category: This is a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants