File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -1041,6 +1041,12 @@ Used as `syntax-propertize-function' in Puppet Mode."
1041
1041
" Align the current block."
1042
1042
(interactive )
1043
1043
(save-excursion
1044
+ ; ; Move point after the end of the string if inside a string to
1045
+ ; ; prevent "Unbalanced parentheses" error by `backward-up-list' .
1046
+ (let ((region (puppet-string-region)))
1047
+ (when region
1048
+ (goto-char (nth 1 region ))
1049
+ (forward-char )))
1044
1050
(backward-up-list )
1045
1051
(let ((beg (point )))
1046
1052
(forward-list )
Original file line number Diff line number Diff line change @@ -615,6 +615,32 @@ class foo {
615
615
}
616
616
}" ))))
617
617
618
+ (ert-deftest puppet-align-block/point-in-string ()
619
+ :tags '(alignment)
620
+ (puppet-test-with-temp-buffer
621
+ "
622
+ class foo {
623
+ $x = {
624
+ 'a'=>1,
625
+ 'foo'=>{
626
+ 'apples'=>1,
627
+ },
628
+ 'metafalica'=>1,
629
+ }
630
+ }"
631
+ (search-forward " tafalica" )
632
+ (puppet-align-block)
633
+ (should (string= (buffer-string ) "
634
+ class foo {
635
+ $x = {
636
+ 'a' => 1,
637
+ 'foo' => {
638
+ 'apples'=>1,
639
+ },
640
+ 'metafalica' => 1,
641
+ }
642
+ }" ))))
643
+
618
644
619
645
; ;;; Imenu
620
646
You can’t perform that action at this time.
0 commit comments