Skip to content

Commit

Permalink
Add evil-select-inner-unrestricted-object
Browse files Browse the repository at this point in the history
  • Loading branch information
tomdl89 committed Apr 30, 2022
1 parent 0327845 commit 8baa566
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
6 changes: 3 additions & 3 deletions evil-commands.el
Original file line number Diff line number Diff line change
Expand Up @@ -1293,15 +1293,15 @@ or line COUNT to the top of the window."

(evil-define-text-object evil-inner-symbol (count &optional beg end type)
"Select inner symbol."
(evil-select-inner-object 'evil-symbol beg end type count))
(evil-select-inner-unrestricted-object 'evil-symbol beg end type count))

(evil-define-text-object evil-a-sentence (count &optional beg end type)
"Select a sentence."
(evil-select-an-object 'evil-sentence beg end type count))

(evil-define-text-object evil-inner-sentence (count &optional beg end type)
"Select inner sentence."
(evil-select-inner-object 'evil-sentence beg end type count))
(evil-select-inner-unrestricted-object 'evil-sentence beg end type count))

(evil-define-text-object evil-a-paragraph (count &optional beg end type)
"Select a paragraph."
Expand All @@ -1311,7 +1311,7 @@ or line COUNT to the top of the window."
(evil-define-text-object evil-inner-paragraph (count &optional beg end type)
"Select inner paragraph."
:type line
(evil-select-inner-object 'evil-paragraph beg end type count t))
(evil-select-inner-unrestricted-object 'evil-paragraph beg end type count t))

(evil-define-text-object evil-a-paren (count &optional beg end type)
"Select a parenthesis."
Expand Down
16 changes: 15 additions & 1 deletion evil-common.el
Original file line number Diff line number Diff line change
Expand Up @@ -3102,7 +3102,7 @@ This can be overridden with TYPE."
(>= (evil-range-end range2)
(evil-range-end range1))))

(defun evil-select-inner-object (thing beg end type &optional count line)
(defun evil-select-inner-unrestricted-object (thing beg end type &optional count line)
"Return an inner text object range of COUNT objects.
If COUNT is positive, return objects following point; if COUNT is
negative, return objects preceding point. If one is unspecified,
Expand Down Expand Up @@ -3132,6 +3132,20 @@ linewise, otherwise it is character wise."
(if line 'line type)
:expanded t)))

(defun evil-select-inner-object (thing beg end type &optional count line)
"Return an inner text object range of COUNT objects.
Selection is restricted to the current line.
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)))
(evil-select-inner-unrestricted-object thing beg end type count line)))

(defun evil-select-an-object (thing beg end type count &optional line)
"Return an outer text object range of COUNT objects.
If COUNT is positive, return objects following point; if COUNT is
Expand Down
6 changes: 5 additions & 1 deletion evil-tests.el
Original file line number Diff line number Diff line change
Expand Up @@ -5945,7 +5945,11 @@ Line 2"))
(evil-test-buffer
"foo\n [ ] bar"
("diW")
"foo\n[b]ar")))
"foo\n[b]ar")
(evil-test-buffer
"fo[o]\nbar"
("diW")
"[\n]bar")))

(ert-deftest evil-test-word-objects-cjk ()
"Test `evil-inner-word' and `evil-a-word' on CJK words"
Expand Down

0 comments on commit 8baa566

Please sign in to comment.