Skip leading whitespace when skipping or killing forwards

When the point is on whitespace between two words skipping forward, or
killing forward, should result in the new point being moved to the next
word:

     foo    bar fox gnu
         ^
=>
     foo    bar fox gnu
                ^

Before this patch the point moved to 'b'.  After this patch the point
moves to the first letter of the next word, 'f'.  Kill forward word now
properly kills 'bar' and moves to the first whitespace letter after
'bar'.  Both are now behaving like FSF Readline.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson 2018-09-16 09:06:36 +02:00
parent ac522cd749
commit 89d2fefbc6

View File

@ -378,6 +378,12 @@ static el_status_t do_forward(el_status_t move)
do {
p = &rl_line_buffer[rl_point];
/* Skip leading whitespace, like FSF Readline */
for ( ; rl_point < rl_end && (p[0] == ' ' || !is_alpha_num(p[0])); rl_point++, p++) {
if (move == CSmove)
right(CSstay);
}
/* Skip to end of word, if inside a word. */
for (; rl_point < rl_end && is_alpha_num(p[0]); rl_point++, p++) {
if (move == CSmove)