Skip to content

Commit

Permalink
Fix out of bounds error
Browse files Browse the repository at this point in the history
  • Loading branch information
EpocSquadron committed Sep 19, 2022
1 parent 2aa659e commit 2c070cb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion helix-core/src/surround.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ pub fn find_nth_closest_pairs_pos(

let mut stack = Vec::with_capacity(2);
let pos = range.from();
let mut close_pos = pos - 1;
let mut close_pos = pos.saturating_sub(1);

for ch in text.chars_at(pos) {
close_pos += 1;
Expand Down
4 changes: 4 additions & 0 deletions helix-term/tests/test/movement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ async fn surround_by_character() -> anyhow::Result<()> {

#[tokio::test]
async fn surround_pair() -> anyhow::Result<()> {
// Works at first character of buffer
// TODO: Adjust test when opening pair failure is fixed
test(("#[(|]#something)", "mim", "#[(|]#something)")).await?;

// Inside a valid pair selects pair
test(("some (#[t|]#ext) here", "mim", "some (#[text|]#) here")).await?;

Expand Down

0 comments on commit 2c070cb

Please sign in to comment.