Skip to content

Commit 95d5c3b

Browse files
committed
Improve delete to avoid inconsistent chat ui
1 parent 26bd0b1 commit 95d5c3b

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

eca-chat.el

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -691,12 +691,14 @@ the prompt/context line."
691691
(item-str-length (-some->> text
692692
(get-text-property 0 'eca-chat-item-str-length))))
693693
(cond
694+
;; expandable item in context area
694695
((and cur-ov
695696
context-item
696697
(not in-prompt?))
697698
(setq-local eca-chat--context (delete context-item eca-chat--context))
698699
(eca-chat--refresh-context))
699700

701+
;; expandable item in prompt
700702
((and cur-ov
701703
item-str-length
702704
in-prompt?)
@@ -705,17 +707,21 @@ the prompt/context line."
705707
(forward-char 1))
706708
(delete-region (- (point) item-str-length) (point)))
707709

710+
;; start of the prompt
708711
((and cur-ov
709-
(<= (point) (overlay-start cur-ov)))
712+
(or (<= (point) (overlay-start cur-ov))
713+
(and (eq 'backward-kill-word this-command)
714+
(string-blank-p (buffer-substring-no-properties (line-beginning-position) (point))))))
710715
(ding))
711716

717+
;; in context area trying to remove a context space separator
712718
((and cur-ov
713719
(overlay-get cur-ov 'eca-chat-context-area)
714720
(and (string= " " (string (char-before (point))))
715721
(not (eolp))))
716-
;; trying to remove a context space separator
717722
)
718723

724+
;; in context area removing a context
719725
((and cur-ov
720726
(overlay-get cur-ov 'eca-chat-context-area)
721727
(string= eca-chat-context-prefix (string (char-before (point)))))

0 commit comments

Comments
 (0)