diff options
| author | Trevor Murphy <trevormurphy@google.com> | 2025-05-19 16:41:31 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-05-19 16:41:31 -0700 |
| commit | 57d9ab3f909109a093ae69730d8666d8202898ab (patch) | |
| tree | 393160a921e60330ef8322dacd68353eb6db8360 /test | |
| parent | 82cbb665bc6a62de59e00aa76dcef29ef3a6c3a2 (diff) | |
Fix moving point (#363)
When replacing text, calculate the cursor offset relative to the start
of the replacement, not the end of the text-to-be-added.
* test/integration/apheleia-it.el (supports-inserting-whitespace): New
test case
* apheleia-rcs.el (apheleia--apply-rcs-patch): Go to start of deletion
text before calculating offsets
Diffstat (limited to 'test')
| -rw-r--r-- | test/integration/apheleia-it.el | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/integration/apheleia-it.el b/test/integration/apheleia-it.el index d4e9238..b48e420 100644 --- a/test/integration/apheleia-it.el +++ b/test/integration/apheleia-it.el @@ -244,3 +244,22 @@ exit 1 (lambda (&rest props) (funcall callback (plist-get props :error)))))) (expect "line4\nline1\n|line2\nline3"))) + +(apheleia-it-deftest supports-inserting-whitespace + "Running `apheleia-format-buffer' preserves point when inserting +whitespace before point" + :scripts `(("apheleia-it" . + ,(apheleia-it-script + :allowed-inputs + '(("function main() {\na=\n return 0\n}" . + "function main() {\n a=\n return 0\n}"))))) + :formatters '((apheleia-it . ("apheleia-it"))) + :steps '((insert "function main() {\na=|\n return 0\n}") + (with-callback + callback + (eval (apheleia-format-buffer + 'apheleia-it nil + :callback + (lambda (&rest props) + (funcall callback (plist-get props :error)))))) + (expect "function main() {\n a=|\n return 0\n}"))) |
