diff --git a/main.lisp b/main.lisp index c5637aad899cdb40a9d12c204a49e55f349a7e81..5ff8d6f2c574894406d218d9d134519a606f1c5c 100644 --- a/main.lisp +++ b/main.lisp @@ -149,10 +149,11 @@ &optional (text-to-cursor (ltk::get-text-to-cursor txt))) "Indents code as you type using the extensible rules of GET-INDENT-LEVEL." (let ((str (ltk:text txt)) - (pos 0) (next) (start) (end) (indent) (token)) + (pos 0) (indent)) (setf pos (- (length text-to-cursor) 1)) (when (and (> pos -1) (<= pos (length str))) (multiple-value-bind (token start end) (find-current-function str pos) + (declare (ignore end)) (when token (setf indent (get-indent-level token)) (setf start (+ start indent)) diff --git a/utils.lisp b/utils.lisp index e11d15cd0d885e991027a09c101ce9c70e05b3dc..6f234ea4a29af923a33780d64ecb45756f73a6db 100644 --- a/utils.lisp +++ b/utils.lisp @@ -184,7 +184,11 @@ start end token) (when next-open (setf start (get-col-integer (strpos-to-textidx code-string next-open))) - (setf end (position #\Space code-string :start next-open :test #'equal)) + (loop :for i :from (1+ next-open) :below (length code-string) + :do (if (member (char code-string i) '(#\Space #\Tab #\Newline) :test #'char=) + (setf next-open i) + (return))) + (setf end (position #\Space code-string :start (1+ next-open) :test #'equal)) (setf token (subseq code-string (+ next-open 1) end))) (values token start end)))