aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src/commands.rs
diff options
context:
space:
mode:
authorCole Helbling2023-11-25 12:55:49 +0000
committerGitHub2023-11-25 12:55:49 +0000
commit8b0ae3d27912799d59e4948ff11d3a5428e32ce4 (patch)
tree579190b16189202c1dbb9ef86c607e9c75616c8d /helix-term/src/commands.rs
parent090ed97e0045bfad1e5bff8b96c61707b996b85a (diff)
bump MSRV to 1.70.0 (#8877)
* rust-toolchain.toml: bump MSRV to 1.70.0 With Firefox 120 released on 21 November 2023, the MSRV is now 1.70.0. * Fix cargo fmt with Rust 1.70.0 * Fix cargo clippy with Rust 1.70.0 * Fix cargo doc with Rust 1.70.0 * rust-toolchain.toml: add clippy component * .github: bump dtolnay/rust-toolchain to 1.70 * helix-term: bump rust-version to 1.70 * helix-view/gutter: use checked_ilog10 to count digits * helix-core/syntax: use MAIN_SEPARATOR_STR constant * helix-view/handlers/dap: use Display impl for displaying process spawn error * WIP: helix-term/commands: use checked math to assert ranges cannot overlap
Diffstat (limited to 'helix-term/src/commands.rs')
-rw-r--r--helix-term/src/commands.rs16
1 files changed, 11 insertions, 5 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index bc54abaa..cd053266 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -1318,7 +1318,7 @@ fn extend_next_long_word_end(cx: &mut Context) {
extend_word_impl(cx, movement::move_next_long_word_end)
}
-/// Separate branch to find_char designed only for <ret> char.
+/// Separate branch to find_char designed only for `<ret>` char.
//
// This is necessary because the one document can have different line endings inside. And we
// cannot predict what character to find when <ret> is pressed. On the current line it can be `lf`
@@ -5606,12 +5606,18 @@ fn shell(cx: &mut compositor::Context, cmd: &str, behavior: &ShellBehavior) {
};
// These `usize`s cannot underflow because selection ranges cannot overlap.
- // Once the MSRV is 1.66.0 (mixed_integer_ops is stabilized), we can use checked
- // arithmetic to assert this.
- let anchor = (to as isize + offset - deleted_len as isize) as usize;
+ let anchor = to
+ .checked_add_signed(offset)
+ .expect("Selection ranges cannot overlap")
+ .checked_sub(deleted_len)
+ .expect("Selection ranges cannot overlap");
let new_range = Range::new(anchor, anchor + output_len).with_direction(range.direction());
ranges.push(new_range);
- offset = offset + output_len as isize - deleted_len as isize;
+ offset = offset
+ .checked_add_unsigned(output_len)
+ .expect("Selection ranges cannot overlap")
+ .checked_sub_unsigned(deleted_len)
+ .expect("Selection ranges cannot overlap");
changes.push((from, to, Some(output)));
}