Improve Ctrl+Left-Arrow Keys behavior (#1531)

* Improve Ctrl+Left-Arrow Keys behavior

* Add CHANGELOG entry
This commit is contained in:
killian 2022-10-15 20:35:26 +02:00 committed by GitHub
parent bd17c6322b
commit 198d9b3299
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 1 deletions

View File

@ -4,6 +4,7 @@
### Features/Changes
- [#1531](https://github.com/lapce/lapce/pull/1531): Improved Ctrl+Left command on spaces at the beginning of a line
- [#1491](https://github.com/lapce/lapce/pull/1491): Added Vim shift+c to delete remainder of line
- [#1508](https://github.com/lapce/lapce/pull/1508): Show in progress when Lapce is self updating
- [#1475](https://github.com/lapce/lapce/pull/1475): Add editor setting: "Cursor Surrounding Lines" which sets minimum number of lines above and below cursor
@ -106,4 +107,4 @@
- [#1191](https://github.com/lapce/lapce/pull/1191): Tone down default inlay hint background color in Lapce dark theme
- [#1227](https://github.com/lapce/lapce/pull/1227): Don't restore cursor mode on undo
- [#1413](https://github.com/lapce/lapce/pull/1413): Disable format-on-save by default. Remember to re-enable this if you want it!
- [#1404](https://github.com/lapce/lapce/pull/1404): Log panics with full backtrace as error
- [#1404](https://github.com/lapce/lapce/pull/1404): Log panics with full backtrace as error

View File

@ -78,6 +78,14 @@ pub fn prev_boundary(&mut self) -> Option<usize> {
if classify_boundary(prop_prev, prop).is_start() {
break;
}
// Stop if line beginning reached, without any non-whitespace characters
if prop_prev == CharClassification::Lf
&& prop == CharClassification::Space
{
break;
}
prop = prop_prev;
candidate = self.inner.pos();
}
@ -469,6 +477,14 @@ fn prev_boundary_should_be_at_word_start() {
assert_eq!(boundary, Some(6));
}
#[test]
fn on_whitespace_prev_boundary_should_be_at_line_start() {
let rope = Rope::from("Hello\n world");
let mut cursor = WordCursor::new(&rope, 10);
let boundary = cursor.prev_boundary();
assert_eq!(boundary, Some(6));
}
#[test]
fn should_get_next_word_boundary() {
let rope = Rope::from("Hello world");