Closed rodrigomorales1 closed 11 months ago
UPDATE: Refer to https://github.com/zkry/yaml-pro/pull/28#issuecomment-1727059015
UPDATE: Refer to https://github.com/zkry/yaml-pro/pull/28#issuecomment-1727059015
In the last two commits 17be0a1 and 52514bd. I've introduced changes to modify behavior in yaml-pro-ts-meta-return
in some scenarios. Please see minimal working examples below. The examples are the same from those of the introduced tests.
(yaml-test-with-temp-text "- 1: one<point>\n"
(yaml-pro-ts-meta-return)
(buffer-substring-no-properties (point-min) (point-max)))
Version from master
branch
"- 1: one
- "
Version from this commit
"- 1: one
-
"
(yaml-test-with-temp-text "- 1: one<point>"
(yaml-pro-ts-meta-return)
(buffer-substring-no-properties
(point-min)
(point-max)))
Both versions produce the same result
"- 1: one
- "
(yaml-test-with-temp-text (concat
"- 1:\n"
"- 2:\n"
"- 3:<point>\n")
(yaml-pro-ts-meta-return)
(buffer-substring-no-properties
(point-min)
(point-max)))
Version from master
branch
"- 1:
- 2:
- 3:
- "
Version from this commit
"- 1:
- 2:
- 3:
-
"
(yaml-test-with-temp-text (concat
"- 1:\n"
" 1.1:\n"
"- 2:\n"
" 2.1:\n"
"- 3:<point>\n"
" 3.1:\n")
(yaml-pro-ts-meta-return)
(buffer-substring-no-properties (point-min) (point-max)))
Version from master
branch
"- 1:
1.1:
- 2:
2.1:
- 3:
3.1:
- "
Version from this commit
"- 1:
1.1:
- 2:
2.1:
- 3:
3.1:
-
"
In the latest commit 7f2b344, I've introduced changes to yaml-pro-ts-move-subtree
to improve its behavior when the file has a trailing newline at the end. I also added some tests. Please see minimal working examples below (the examples are the same from those of the tests).
(yaml-test-with-temp-text (concat
"<point>1:\n"
" 1.1: null\n"
"2:\n"
" 2.1: null\n"
"3:\n"
" 3.1: null\n")
(yaml-pro-ts-move-subtree-down)
(buffer-substring-no-properties
(point-min)
(point-max)))
Both versions produce the same result
"2:
2.1: null
1:
1.1: null
3:
3.1: null
"
(yaml-test-with-temp-text (concat
"1:<point>\n"
" 1.1: null\n"
"2:\n"
" 2.1: null\n"
"3:\n"
" 3.1: null\n")
(yaml-pro-ts-move-subtree-down)
(buffer-substring-no-properties
(point-min)
(point-max)))
Both versions produce the same result
"2:
2.1: null
1:
1.1: null
3:
3.1: null
"
(yaml-test-with-temp-text (concat
"1:\n"
" 1.1: null\n"
"2:<point>\n"
" 2.1: null\n"
"3:\n"
" 3.1: null")
(yaml-pro-ts-move-subtree-down)
(buffer-substring-no-properties (point-min) (point-max)))
Both versions produce the same result
"1:
1.1: null
3:
3.1: null
2:
2.1: null"
(yaml-test-with-temp-text (concat
"1:\n"
" 1.1: null\n"
"2:<point>\n"
" 2.1: null\n"
"3:\n"
" 3.1: null\n"
"\n"
"\n"
"\n")
(yaml-pro-ts-move-subtree-down)
(buffer-substring-no-properties (point-min) (point-max)))
Version from master
branch
"1:
1.1: null
3:
3.1: null
2:
2.1: null"
Version from this commit
"1:
1.1: null
3:
3.1: null
2:
2.1: null
"
Thanks for this contribution. This is great!
The introduced tests can be run by executing the following command in the root directory of the project.
emacs -batch \ -l ert \ -l yaml-pro-edit.el \ -l yaml-pro.el \ -l tests/yaml-pro-ts.el \ -f ert-run-tests-batch-and-exit
NOTE: In the future, I'm planning to add more tests. First, I've written these simple tests so @zkry (creator of this project) can confirm that this is correct behavior. Then, I'll write more complex tests.
Here's proof that these tests run successfully: