From 83d05f917052b81b943331d0bc03d5e0bae08cae Mon Sep 17 00:00:00 2001 From: axel Date: Sat, 11 Mar 2006 21:56:12 +1000 Subject: [PATCH] Move to end of current token on completion darcs-hash:20060311115612-ac50b-70f15c50b6cb8ad89d84ae6c8a3ffc4b7551223b.gz --- doc_src/doc.hdr | 1 - reader.c | 13 +++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/doc_src/doc.hdr b/doc_src/doc.hdr index 53bb25188..91bd4f83d 100644 --- a/doc_src/doc.hdr +++ b/doc_src/doc.hdr @@ -1191,7 +1191,6 @@ g++, javac, java, gcj, lpr, doxygen, whois, find) - Do not actually load/parse .fish_history, only mmap it and use some clever string handling. Should save ~150 kB of memory permanently, but is very hard to implement. - command specific wildcarding (use case * instead of case '*', etc.) - show the whole list of commands on using tab on an empty commandline -- Automatically move cursor to the end of the current token before completing - Map variables. (export only the values. When expanding with no key specified, expand to all values.) - Descriptions for variables using 'set -d'. - Parse errors should when possible honor IO redirections diff --git a/reader.c b/reader.c index 4270c8e6b..07ba4ef2f 100644 --- a/reader.c +++ b/reader.c @@ -2446,11 +2446,19 @@ wchar_t *reader_readline() if( comp_empty ) { const wchar_t *begin, *end; + const wchar_t *token_begin, *token_end; wchar_t *buffcpy; - + int len; + int cursor_steps; + parse_util_cmdsubst_extent( data->buff, data->buff_pos, &begin, &end ); - int len = data->buff_pos - (data->buff - begin); + parse_util_token_extent( begin, data->buff_pos - (begin-data->buff), &token_begin, &token_end, 0, 0 ); + cursor_steps = token_end - data->buff- data->buff_pos; + data->buff_pos += cursor_steps; + move_cursor( cursor_steps ); + + len = data->buff_pos - (data->buff - begin); buffcpy = wcsndup( begin, len ); //fwprintf( stderr, L"String is %ls\n", buffcpy ); @@ -2463,6 +2471,7 @@ wchar_t *reader_readline() remove_duplicates( &comp ); free( buffcpy ); + } if( (comp_empty = handle_completions( &comp ) ) )