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

Wrong regions of text objects #106

Open
dvzubarev opened this issue Jan 15, 2023 · 0 comments · May be fixed by #114
Open

Wrong regions of text objects #106

dvzubarev opened this issue Jan 15, 2023 · 0 comments · May be fixed by #114

Comments

@dvzubarev
Copy link

dvzubarev commented Jan 15, 2023

Consider this simple Org file:

* tree
text
** subtree
subtree

Set the point on the first line (* t|ree), visually select this line pressing V and quit visual state with ESC.
Then move the point to the ** subtree and try to delete this subtree using a text object evil-org-a-subtree
(eval (apply #'evil-delete (evil-org-a-subtree))).

After that the buffer looks like:

* t

Looking into the code, I've found this function

(defun evil-org-select-an-element (element)
  "Select an org ELEMENT."
  (list (min (region-beginning) (org-element-property :begin element))
        (org-element-property :end element)))

Documentation of region-beginning: Return the integer value of point or mark, whichever is smaller.
Since in my case, mark has value smaller than value of point, the region returned by evil-org-select-an-element is wrong and includes not only subtree but outer tree as well.
I don't know what is rationale for using such an expression here (min (region-beginning) (org-element-property :begin element)).
If the point was to restrict the lower bound of an element to the user point, then one can replace (region-beginning) with (point) .
Another option just return (org-element-property :begin element).

45mg added a commit to 45mg/evil-org-mode that referenced this issue Feb 20, 2024
As described in Issue Somelauw#106. I still don't understand why
`region-beginning` was used, but replacing it with `point` gives the
exact same behavior, minus the brokenness when visual-mode has been
previously activated somewhere outside the subtree at point.
45mg added a commit to 45mg/evil-org-mode that referenced this issue Feb 20, 2024
As described in Issue Somelauw#106. I still don't understand why
`region-beginning` was used, but replacing it with `point` gives the
exact same behavior, minus the brokenness when visual-mode has been
previously activated somewhere outside the subtree at point.
45mg added a commit to 45mg/evil-org-mode that referenced this issue Feb 20, 2024
As described in Issue Somelauw#106. I still don't understand why
`region-beginning` was used, but replacing it with `point` gives the
exact same behavior, minus the brokenness when visual-mode has been
previously activated somewhere above the subtree at point.
@45mg 45mg linked a pull request Feb 20, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant