Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Select inner tag even when empty #1816

Merged
merged 1 commit into from
Aug 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions evil-common.el
Original file line number Diff line number Diff line change
Expand Up @@ -1365,13 +1365,11 @@ last successful match (that caused COUNT to reach zero)."

(defun evil-up-xml-tag (&optional count)
"Move point to the end or beginning of balanced xml tags.
OPEN and CLOSE should be characters identifying the opening and
closing parenthesis, respectively. If COUNT is greater than zero
point is moved forward otherwise it is moved backwards. Whenever
an opening delimiter is found the COUNT is increased by one, if a
closing delimiter is found the COUNT is decreased by one. The
motion stops when COUNT reaches zero. The match-data reflects the
last successful match (that caused COUNT to reach zero)."
If COUNT is greater than zero point is moved forward otherwise it is moved
backwards. Whenever an opening delimiter is found the COUNT is increased by
one, if a closing delimiter is found the COUNT is decreased by one. The motion
stops when COUNT reaches zero. The match data reflects the last successful
match (that caused COUNT to reach zero)."
(let* ((dir (if (> (or count 1) 0) +1 -1))
(count (abs (or count 1)))
(op (if (> dir 0) 1 2))
Expand All @@ -1394,7 +1392,7 @@ last successful match (that caused COUNT to reach zero)."
(string= (car tags) (match-string cl)))
;; in backward direction we only accept matching
;; tags. If the current tag is a free opener
;; without matching closing tag, the subsequents
;; without matching closing tag, the subsequent
;; test will make us ignore this tag
(pop tags))
((and (> dir 0))
Expand Down Expand Up @@ -3339,8 +3337,7 @@ from the range."
((and (not inclusive) (= (abs (or count 1)) 1))
(let ((rng (evil-select-block #'evil-up-xml-tag beg end type count nil t)))
(if (or (and beg (= beg (evil-range-beginning rng))
end (= end (evil-range-end rng)))
(= (evil-range-beginning rng) (evil-range-end rng)))
end (= end (evil-range-end rng))))
(evil-select-block #'evil-up-xml-tag beg end type count t)
rng)))
(t
Expand Down
9 changes: 8 additions & 1 deletion evil-tests.el
Original file line number Diff line number Diff line change
Expand Up @@ -7175,7 +7175,14 @@ test hello <a href=\"/deed.zh\">Creative Commons</a>
:visual-end "»"
"<button foo=\"bar\" onClick={() => fnbody()}>inner [t]ext</button>"
("vit")
"<button foo=\"bar\" onClick={() => fnbody()}>«inner tex[t]»</button>")))
"<button foo=\"bar\" onClick={() => fnbody()}>«inner tex[t]»</button>"))
(ert-info ("Inner tag is selected, even when empty")
(evil-test-buffer
:visual-start "«"
:visual-end "»"
"<p>foo<b [c]lass =\"bold\"></b>qux</p>"
("cit" "bar")
"<p>foo<b class =\"bold\">bar</b>qux</p>")))

;;; Visual state

Expand Down
Loading