aboutsummaryrefslogtreecommitdiff
path: root/test-org-link-edit.el
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2017-03-03 00:02:26 -0500
committerKyle Meyer <kyle@kyleam.com>2017-03-03 00:26:30 -0500
commit48ebfc757f713484b5427d0ca775fd1ae62f4775 (patch)
tree2cfd928085d61116c687ab727367edec688f95dc /test-org-link-edit.el
parentf90ba3c0faed5dfd4f50ab2044a86858104ab00e (diff)
downloadorg-link-edit-48ebfc757f713484b5427d0ca775fd1ae62f4775.tar.gz
barf: Fix edge cases where point is beyond link
When a point is on a blank space beyond the link but before the next element, org-element-context considers point to be a part of the link. This leads to incorrect behavior (shown in the added tests) when either barfing backward or forward. Avoid these issues by moving point to the beginning of the link before deleting the old link and inserting a new one. As a bonus, this makes some of the later goto-char calculations unnecessary.
Diffstat (limited to 'test-org-link-edit.el')
-rw-r--r--test-org-link-edit.el36
1 files changed, 36 insertions, 0 deletions
diff --git a/test-org-link-edit.el b/test-org-link-edit.el
index e37be95..6cf936a 100644
--- a/test-org-link-edit.el
+++ b/test-org-link-edit.el
@@ -88,6 +88,15 @@ otherwise place the point at the beginning of the inserted text."
"\[\[http://orgmode.org/\]\[Org's\]\] .?.?"
(org-link-edit-forward-slurp)
(buffer-string))))
+ ;; Slurping blob with point beyond link, but technically still
+ ;; within link element.
+ (should
+ (string=
+ "Org's \[\[http://orgmode.org/\]\[website is\]\]"
+ (org-test-with-temp-text
+ "Org's \[\[http://orgmode.org/\]\[website\]\] <point> is"
+ (org-link-edit-forward-slurp)
+ (buffer-string))))
;; Slurp two blobs into plain link.
(should
(string=
@@ -188,6 +197,15 @@ website is"
"Here ... <point>\[\[http://orgmode.org/\]\[Org's\]\] website."
(org-link-edit-backward-slurp)
(buffer-string))))
+ ;; Slurping blob with point beyond link, but technically still
+ ;; within link element.
+ (should
+ (string=
+ "\[\[http://orgmode.org/\]\[Org's website\]\] is"
+ (org-test-with-temp-text
+ "Org's \[\[http://orgmode.org/\]\[website\]\] <point> is"
+ (org-link-edit-backward-slurp)
+ (buffer-string))))
;; Slurp two blobs into plain link.
(should
(string=
@@ -283,6 +301,15 @@ website is"
"Org's <point>\[\[http://orgmode.org/\]\[website\]\] is"
(org-link-edit-forward-barf)
(buffer-string))))
+ ;; Barfing last blob with point beyond link, but technically still
+ ;; within link element.
+ (should
+ (string=
+ "Org's \[\[http://orgmode.org/\]\] website is"
+ (org-test-with-temp-text
+ "Org's \[\[http://orgmode.org/\]\[website\]\] <point> is"
+ (org-link-edit-forward-barf)
+ (buffer-string))))
;; Barf last blob with puctuation.
(should
(string=
@@ -333,6 +360,15 @@ website is"
"Org's <point>\[\[http://orgmode.org/\]\[website\]\] is"
(org-link-edit-backward-barf)
(buffer-string))))
+ ;; Barfing last blob with point beyond link, but technically still
+ ;; within link element.
+ (should
+ (string=
+ "Org's website \[\[http://orgmode.org/\]\] is"
+ (org-test-with-temp-text
+ "Org's \[\[http://orgmode.org/\]\[website\]\] <point> is"
+ (org-link-edit-backward-barf)
+ (buffer-string))))
;; Barf last blob with puctuation.
(should
(string=