[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/go-mode 3bc7479 450/495: Fix infinite loop in fill-region
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/go-mode 3bc7479 450/495: Fix infinite loop in fill-region |
Date: |
Sat, 7 Aug 2021 09:06:07 -0400 (EDT) |
branch: elpa/go-mode
commit 3bc74790c41e071cc3a9da97b95bb01c78cc8784
Author: Muir Manders <muir@mnd.rs>
Commit: Peter Sanford <psanford@sanford.io>
Fix infinite loop in fill-region
Calling fill-region on code (as opposed to comments) was looping
forever. This is because fill-region keeps going until it reaches the
end of the region, but our go--fill-forward-paragraph was giving up if
it didn't see a comment. Now we just fall back to forward-paragraph so
we can be sure we will make it out of the region.
Closes: #297 [via git-merge-pr]
---
go-mode.el | 13 ++++++++++---
test/go-fill-paragraph-test.el | 17 ++++++++++++++++-
2 files changed, 26 insertions(+), 4 deletions(-)
diff --git a/go-mode.el b/go-mode.el
index 85d1bf5..5691959 100644
--- a/go-mode.el
+++ b/go-mode.el
@@ -723,8 +723,8 @@ thing for comments."
(while (and (not done) (not (zerop arg)))
;; If we are moving backwards and aren't currently looking at a
;; comment, move back one line. This is to make sure
- ;; (go--file-forward-paragraph -1) always works properly as the
- ;; inverse of (go--file-forward-paragraph 1).
+ ;; (go--fill-forward-paragraph -1) always works properly as the
+ ;; inverse of (go--fill-forward-paragraph 1).
(when (and
(= single -1)
(not (go-in-comment-p))
@@ -744,7 +744,14 @@ thing for comments."
(setq saw-comment t))
(if (not saw-comment)
- (setq done t)
+ (progn
+ ;; In fill-region case user may have selected a region
+ ;; with non-comments. fill-region will loop forever
+ ;; until it makes it to the end of the region, so just
+ ;; fall back to `forward-paragraph' so we make progress.
+ (when mark-active
+ (setq arg (forward-paragraph arg)))
+ (setq done t))
;; If we are going backwards, back up one more line so
;; we are on the line before the comment.
(when (= single -1)
diff --git a/test/go-fill-paragraph-test.el b/test/go-fill-paragraph-test.el
index 5775018..8c5deda 100644
--- a/test/go-fill-paragraph-test.el
+++ b/test/go-fill-paragraph-test.el
@@ -148,7 +148,6 @@ func main() {
}"
))
-
(ert-deftest go--fill-paragraph-block-region ()
(go--should-fill
"
@@ -198,3 +197,19 @@ func main() {
/////////////////////
}"
))
+
+(ert-deftest go--fill-paragraph-code-region ()
+ (go--should-fill
+ "
+func main() {
+< if something() {
+ somethingElse()
+ }
+>}"
+
+ ;; important thing is we don't get stuck in an infinite loop
+ "
+func main() {
+ if something() { somethingElse() }
+}"
+ ))
- [nongnu] elpa/go-mode 3f60838 424/495: Move testdata under test/ directory., (continued)
- [nongnu] elpa/go-mode 3f60838 424/495: Move testdata under test/ directory., ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 3ba1982 427/495: Handle indentation for nested dangling operators, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode f6b1398 429/495: Fix filename handling in godoc-gogetdoc, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 00e72cd 431/495: Update default for godoc-and-godef-command, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 6b67088 432/495: Support trailing commas as dangling operators., ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 8ddf0b3 433/495: Speed up go-goto-opening-parenthesis, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode fdc1545 436/495: Fix indent for case statement comments, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode d387378 438/495: indent: handle comments after multiline case lists, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode fbf2544 444/495: Improve fill-paragraph for comment blocks., ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode e7e0157 447/495: indent: fix indent at top level of file, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 3bc7479 450/495: Fix infinite loop in fill-region,
ELPA Syncer <=
- [nongnu] elpa/go-mode 88ffc9e 452/495: Add github action yaml file to run ert tests, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 4f15abf 449/495: Fix fill-paragraph for certain block comments., ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode a13b814 448/495: Add option to reuse a single buffer for godoc, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode a82369b 453/495: Readme: add basic information about gopls., ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 839190b 455/495: Run all tests in GH CI, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 7248358 462/495: Fontify type names in type switch statements, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 4fabba6 464/495: Small fix for fontification of array types, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 656590a 463/495: Fontify qualified composite literal types., ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode d304565 474/495: Fix signature fontification after comments., ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode e9b9c0e 473/495: Add some fontification faces for go-dot-mod-mode., ELPA Syncer, 2021/08/07