Skip to content

Commit d80b2ff

Browse files
authored
FIX: Single semicolon at beginning was indented. (#454)
The workaround here is to add a double semicolon, iff the start comment is a single semicolon. This also required some fixing of the whitespace calculations. This commit is for issue 387 (#387).
1 parent 464517d commit d80b2ff

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

snippets/prog-mode/commentblock

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,20 @@ ${1:$(let* ((col (current-column))
1515
${1:$(let* ((col (current-column))
1616
(str "")
1717
(start (yas-trimmed-comment-start))
18+
(start (if (string= start ";") ";;" start))
1819
(end (yas-trimmed-comment-end)))
1920
(while (< (length str) (ffloor (/ (- 78.0 (+ col (length start) (string-width yas-text) (length end))) 2.0)))
2021
(setq str (concat str " ")))
21-
(concat start str))} ${1:comment} ${1:$(let* ((col (current-column))
22-
(str "")
23-
(start (yas-trimmed-comment-start))
24-
(end (yas-trimmed-comment-end)))
25-
(while (< (length str) (- 79.0 (if (eq (mod (string-width yas-text) 2) 1) (- col 1) col) (length end)))
26-
(setq str (concat str " ")))
22+
(concat start str))} ${1:comment} ${1:$(
23+
let* ((col (current-column))
24+
(str "")
25+
(start (yas-trimmed-comment-start))
26+
(start (if (string= start ";") ";;" start))
27+
(end (yas-trimmed-comment-end)))
28+
(while (< (length str)
29+
(- 79 (length end)
30+
(if (eq (mod (+ (string-width yas-text) (length start) (length end)) 2) 1) (- col 1) col)))
31+
(setq str (concat str " ")))
2732
(concat str end))}
2833
${1:$(let* ((col (current-column))
2934
(str "")

0 commit comments

Comments
 (0)