From a393f2e1dc0fb163d5df00ffc6f29ab4350619e7 Mon Sep 17 00:00:00 2001 From: Albert Cervin Date: Wed, 31 Jan 2024 09:01:54 +0100 Subject: Make next-word stop at eol It felt a little too greedy --- src/dged/buffer.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/dged/buffer.c b/src/dged/buffer.c index 0a7dd16..e114bef 100644 --- a/src/dged/buffer.c +++ b/src/dged/buffer.c @@ -269,7 +269,8 @@ static void write_line(struct text_chunk *chunk, void *userdata) { } static bool is_word_break(uint8_t c) { - return c == ' ' || c == '.' || c == '(' || c == ')'; + return c == ' ' || c == '.' || c == '(' || c == ')' || c == '[' || c == ']' || + c == '{' || c == '}'; } static bool is_word_char(uint8_t c) { return !is_word_break(c); } @@ -591,8 +592,12 @@ struct location buffer_next_word(struct buffer *buffer, struct location dot) { return res.at; } + uint32_t traveled = dot.col - res.at.col; + res = find_next_in_line(buffer, res.at, is_word_char); - if (!res.found) { + + // make a stop at the end of the line as well + if (!res.found && traveled == 0) { moveh(buffer, 1, &res.at); } -- cgit v1.2.3