Skip to content

Commit

Permalink
Only restrict objects when current line is not empty (#1721)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomdl89 authored Nov 22, 2022
1 parent 5ce46a1 commit 2e85761
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions evil-common.el
Original file line number Diff line number Diff line change
Expand Up @@ -3153,16 +3153,18 @@ linewise, otherwise it is character wise."

(defun evil-select-inner-restricted-object (thing beg end type &optional count line)
"Return an inner text object range of COUNT objects.
Selection is restricted to the current line.
Selection is restricted to the current line, unless it is empty.
If COUNT is positive, return objects following point; if COUNT is
negative, return objects preceding point. If one is unspecified,
the other is used with a negative argument. THING is a symbol
understood by `thing-at-point'. BEG, END and TYPE specify the
current selection. If LINE is non-nil, the text object should be
linewise, otherwise it is character wise."
(save-restriction
(narrow-to-region (save-excursion (beginning-of-line) (point))
(save-excursion (end-of-line) (point)))
(let ((start (save-excursion (beginning-of-line) (point)))
(end (save-excursion (end-of-line) (point))))
(when (/= start end)
(narrow-to-region start end)))
(evil-select-inner-object thing beg end type count line)))

(defun evil-select-an-object (thing beg end type count &optional line)
Expand Down Expand Up @@ -3246,16 +3248,18 @@ linewise, otherwise it is character wise."

(defun evil-select-a-restricted-object (thing beg end type &optional count line)
"Return an outer text object range of COUNT objects.
Selection is restricted to the current line.
Selection is restricted to the current line, unless it is empty.
If COUNT is positive, return objects following point; if COUNT is
negative, return objects preceding point. If one is unspecified,
the other is used with a negative argument. THING is a symbol
understood by thing-at-point. BEG, END and TYPE specify the
current selection. If LINE is non-nil, the text object should be
linewise, otherwise it is character wise."
(save-restriction
(narrow-to-region (save-excursion (beginning-of-line) (point))
(save-excursion (end-of-line) (point)))
(let ((start (save-excursion (beginning-of-line) (point)))
(end (save-excursion (end-of-line) (point))))
(when (/= start end)
(narrow-to-region start end)))
(evil-select-an-object thing beg end type count line)))

(defun evil--get-block-range (op cl selection-type)
Expand Down

0 comments on commit 2e85761

Please sign in to comment.