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

added bounds check to prevent panic #4043

Closed
wants to merge 0 commits into from

Conversation

v4nderstruck
Copy link
Contributor

addresses my own issue here #4038

simple bounds check should do the trick

Copy link
Member

@the-mikedavis the-mikedavis left a comment

Choose a reason for hiding this comment

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

This prevents the panic but doesn't solve the underlying issue that causes the panic.

We panic here because the offset points to a part of the text that doesn't exist after :formating. Instead of handling the panic here, we should add a call to view.ensure_cursor_in_view(doc, editor.config().scrolloff) to the :format implementation (in this block:

doc.apply(&format, view_id);
doc.append_changes_to_history(view_id);
doc.detect_indent_and_line_ending();
if let Modified::SetUnmodified = modified {
doc.reset_modified();
}
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants