Skip to content

Commit ad5e510

Browse files
authored
Merge pull request #306 from tanioka256/match-string
Avoid args-out-of-range errors in match-string calls
2 parents be81dd7 + 5af927d commit ad5e510

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

chatgpt-shell.el

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3179,11 +3179,12 @@ Of the form
31793179
(line-beginning-position)))
31803180
(end (region-end)))
31813181
;; Barf trailing space from selection.
3182-
(when (string-match "[ \n\t]+$"
3183-
(buffer-substring-no-properties
3184-
start
3185-
end))
3186-
(setq end (- end (length (match-string 0)))))
3182+
(let ((text (buffer-substring-no-properties
3183+
start
3184+
end)))
3185+
(when (string-match "[ \n\t]+$"
3186+
text)
3187+
(setq end (- end (length (match-string 0 text))))))
31873188
(list (cons :start start)
31883189
(cons :end end)
31893190
(cons :buffer (current-buffer))

0 commit comments

Comments
 (0)