diff --git a/scheme/cmdline.scm b/scheme/cmdline.scm index 92f2c48..a365b20 100644 --- a/scheme/cmdline.scm +++ b/scheme/cmdline.scm @@ -59,19 +59,20 @@ (integer? (token-cursor-pos token)))) (define-record-type to-complete :to-complete - (make-to-complete prefix) + (make-to-complete prefix pos) to-complete? - (prefix to-complete-prefix)) + (prefix to-complete-prefix) + (pos to-complete-pos)) (define-record-discloser :to-complete (lambda (r) - `(to-complete ,(to-complete-prefix r)))) + `(to-complete ,(to-complete-prefix r) ,(to-complete-pos r)))) (define to-complete-without-prefix? to-complete-prefix) -(define (make-empty-to-complete) - (make-to-complete #f)) +(define (make-empty-to-complete pos) + (make-to-complete #f pos)) (define operator-chars (char-set #\& #\| #\< #\> #\, #\;)) @@ -117,8 +118,6 @@ (define (lex-port cursor-index port) (let lp ((c (peek-char port)) (tokens '())) - (display (list c (current-column port))) - (newline) (cond ((eof-object? c) (reverse tokens)) @@ -137,7 +136,7 @@ (read-char port) (lp (peek-char port) (if (and cursor-index (= cursor-index pos)) - (cons (make-empty-to-complete) tokens) + (cons (make-empty-to-complete pos) tokens) tokens)))) (else (let ((token (lex-token cursor-index port))) @@ -214,7 +213,7 @@ ((to-complete? t) t) ((cursor-on-token? t) - (make-to-complete (token-token t))) + (make-to-complete (token-token t) (token-start-pos t))) (else (token-token t)))) @@ -344,7 +343,9 @@ (let lp ((tokens tokens)) (cond ((null? tokens) - #f) + (make-command-line + (make-command (make-to-complete #f 0) '() '()) + '() #f)) ((parse-command-line-carefully tokens) => (lambda (v) v)) (else