From 8776b96879a48e3dea5077e06f19fe3388de62a0 Mon Sep 17 00:00:00 2001 From: Nathan Vegdahl Date: Tue, 15 Jun 2021 23:18:52 -0700 Subject: [PATCH] Fix bug in go-to-line. Wasn't checking for maximum against the lines in the file. --- Cargo.lock | 6 +++--- src/editor/mod.rs | 5 ++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 91b5df0..839a323 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -520,13 +520,13 @@ dependencies = [ [[package]] name = "unicode-segmentation" version = "1.6.0" -source = "git+https://github.com/unicode-rs/unicode-segmentation.git#fbba2a660b38dad86eebcd7fe73138c5cbfb9469" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e83e153d1053cbb5a118eeff7fd5be06ed99153f00dbcd8ae310c5fb2b22edc0" [[package]] name = "unicode-segmentation" version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e83e153d1053cbb5a118eeff7fd5be06ed99153f00dbcd8ae310c5fb2b22edc0" +source = "git+https://github.com/unicode-rs/unicode-segmentation.git#fbba2a660b38dad86eebcd7fe73138c5cbfb9469" [[package]] name = "unicode-width" diff --git a/src/editor/mod.rs b/src/editor/mod.rs index 74367e2..af21ae6 100644 --- a/src/editor/mod.rs +++ b/src/editor/mod.rs @@ -564,7 +564,10 @@ impl Editor { ); } - let pos = self.buffer.text.line_to_char(n); + let pos = self + .buffer + .text + .line_to_char(n.min(self.buffer.text.len_lines())); let pos = self.formatter.set_horizontal( &self.buffer.text, pos,