File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed
Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change 116116 (let ((secs (/ (float ms) 1000 )))
117117 (format " %. 2f s" secs)))
118118
119+ (defun eca-rewrite--normalize-start-region (start )
120+ " Normalize START region.
121+ If chars from START until bol are all spaces return bol,
122+ otherwise START."
123+ (save-excursion
124+ (goto-char start)
125+ (let ((bol (line-beginning-position )))
126+ (if (string-match-p " \\ `[ \t ]*\\ '"
127+ (buffer-substring bol start))
128+ bol
129+ start))))
130+
119131(defun eca-rewrite--overlay-menu-str (ov label )
120132 " Return the before-string for overlay OV.
121133LABEL is the base text prefix."
@@ -484,7 +496,7 @@ PROMPT is the instructions prompt for the LLM."
484496 (eca-assert-session-running (eca-session))
485497 (let* ((existing-ov (eca-rewrite--overlay-at-point))
486498 (start (cond (existing-ov (overlay-start existing-ov))
487- ((use-region-p ) (region-beginning ))
499+ ((use-region-p ) (eca-rewrite--normalize-start- region ( region -beginning) ))
488500 (t (or (car (bounds-of-thing-at-point 'defun ))
489501 (car (bounds-of-thing-at-point 'paragraph ))
490502 (user-error " No region selected or existing-ov rewrite overlay" )))))
You can’t perform that action at this time.
0 commit comments