[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/swift-mode e65a80a 465/496: Support full-indent for switch
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/swift-mode e65a80a 465/496: Support full-indent for switch cases |
Date: |
Sun, 29 Aug 2021 11:34:29 -0400 (EDT) |
branch: elpa/swift-mode
commit e65a80a659c74d0a62b00dff183a0f7fc8385ce1
Author: Josh Caswell <josh@charybdis>
Commit: taku0 <taku0@users.noreply.github.com>
Support full-indent for switch cases
When `swift-mode:switch-case-offset` is set equal to the basic offset,
lines following a `case` inside a `switch` should still be indented.
Change the offset calculation to fall back to `swift-mode:basic-offset`
if the difference between the offsets is 0 (or less).
Resolves #166
---
swift-mode-indent.el | 3 ++-
test/swift-files/indent/statements.swift | 16 ++++++++++++++++
2 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/swift-mode-indent.el b/swift-mode-indent.el
index 92e2e68..687f1b3 100644
--- a/swift-mode-indent.el
+++ b/swift-mode-indent.el
@@ -689,7 +689,8 @@ declaration and its offset is `swift-mode:basic-offset'."
(goto-char (swift-mode:token:start previous-token))
(swift-mode:find-parent-and-align-with-next
swift-mode:statement-parent-tokens
- (- swift-mode:basic-offset swift-mode:switch-case-offset)))
+ (let ((relative-case-offset (- swift-mode:basic-offset
swift-mode:switch-case-offset)))
+ (if (<= relative-case-offset 0) swift-mode:basic-offset
relative-case-offset))))
;; Before ; on the current line
((and next-is-on-current-line (eq next-type '\;))
diff --git a/test/swift-files/indent/statements.swift
b/test/swift-files/indent/statements.swift
index fa3cbab..87bdf65 100644
--- a/test/swift-files/indent/statements.swift
+++ b/test/swift-files/indent/statements.swift
@@ -923,6 +923,22 @@ switch foo {
// swift-mode:test:eval (setq-local swift-mode:switch-case-offset 0)
+// swift-mode:test:eval (setq-local swift-mode:switch-case-offset 4)
+
+switch foo {
+ case foo:
+ foo()
+ if let x = y {
+ bar()
+ }
+ foo()
+ default:
+ foo()
+ foo()
+}
+
+// swift-mode:test:eval (setq-local swift-mode:switch-case-offset 0)
+
// Labeled statements
- [nongnu] elpa/swift-mode 19e6974 371/496: Abstract syntax-ppss, (continued)
- [nongnu] elpa/swift-mode 19e6974 371/496: Abstract syntax-ppss, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 69efea4 386/496: Add `current-defun-name`, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 7739e49 387/496: Bump version to 4.1.0, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode ada5576 389/496: Merge pull request #144 from nhojb/which_function_mode_fix, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 4e22279 390/496: Bump version to 4.1.1, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 0e6b044 408/496: Make highlighting symbols in standard library optional, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 71c82e9 418/496: Add compilation before testing, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 1759977 440/496: Fix typo, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 323bb97 457/496: Update copyright notices, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 7d93c75 464/496: Bump version to 8.1.0, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode e65a80a 465/496: Support full-indent for switch cases,
ELPA Syncer <=
- [nongnu] elpa/swift-mode 9676f90 485/496: Update CI versions, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode e9e493e 487/496: Set `comment-line-break-function`, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode fd3c824 484/496: Bump version to 8.2.0, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 23b9227 492/496: Support async/await, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 6546ad5 040/496: Fix auto-mode-alist regex, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 760710c 031/496: fixup! Update readme, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode bf224ad 049/496: Organize links, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode e46584a 054/496: Add @bbatsov to contributors in readme, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 5adb37d 070/496: More indentation tests, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 34be010 074/496: Update features in readme, ELPA Syncer, 2021/08/29