[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/swift-mode 2c67d92 213/496: Fix indentation of the closure
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/swift-mode 2c67d92 213/496: Fix indentation of the closure arguments inside parentheses |
Date: |
Sun, 29 Aug 2021 11:33:38 -0400 (EDT) |
branch: elpa/swift-mode
commit 2c67d9246fbe57629c8d5685d0abfde3deb96989
Author: ap4y <lod@pisem.net>
Commit: ap4y <lod@pisem.net>
Fix indentation of the closure arguments inside parentheses
---
swift-mode.el | 16 ++++++++++++++--
test/indentation-tests.el | 46 ++++++++++++++++++++++++++++++++++++++++++++--
2 files changed, 58 insertions(+), 4 deletions(-)
diff --git a/swift-mode.el b/swift-mode.el
index 9e4408f..420bb09 100644
--- a/swift-mode.el
+++ b/swift-mode.el
@@ -676,11 +676,23 @@ You can send text to the REPL process from other buffers
containing source.
;; Parenthesis, braces and brackets
(modify-syntax-entry ?\( "()" table)
(modify-syntax-entry ?\) ")(" table)
- (modify-syntax-entry ?\{ "(}" table)
- (modify-syntax-entry ?\} "){" table)
(modify-syntax-entry ?\[ "(]" table)
(modify-syntax-entry ?\] ")[" table)
+ ;; HACK: This is not a correct syntax table definition
+ ;; for the braces, but it allows us disable smie indentation
+ ;; based on syntax-table. Default behaviour doesn't work with
+ ;; closures in method arguments. For example:
+ ;;
+ ;; foo.bar(10,
+ ;; closure: {
+ ;; })
+ ;;
+ ;; With enabled syntax table, smie doesn't respect closing brace, so
+ ;; it's impossible to provide custom indentation rules
+ (modify-syntax-entry ?\{ "w" table)
+ (modify-syntax-entry ?\} "w" table)
+
table))
(defvar swift-mode-map
diff --git a/test/indentation-tests.el b/test/indentation-tests.el
index d3ec032..d9816cc 100644
--- a/test/indentation-tests.el
+++ b/test/indentation-tests.el
@@ -1568,7 +1568,7 @@ UIView.animateWithDuration(1.0,
" "
UIView.animateWithDuration(1.0,
animations: {
-|})
+ |})
")
(check-indentation anonymous-function-as-a-argument/2
@@ -1581,7 +1581,49 @@ UIView.animateWithDuration(
UIView.animateWithDuration(
1.0,
animations: {
-|})
+ |})
+")
+
+(check-indentation anonymous-function-as-a-argument/3
+ "
+func foo() {
+ UIView.animateWithDuration(1.0,
+ animations: {
+ |}
+ ) {
+ completed in
+ }
+}
+" "
+func foo() {
+ UIView.animateWithDuration(1.0,
+ animations: {
+ |}
+ ) {
+ completed in
+ }
+}
+")
+
+(check-indentation anonymous-function-as-a-argument/4
+ "
+func foo() {
+ UIView.animateWithDuration(1.0,
+ animations: {
+ }
+|) {
+ completed in
+ }
+}
+" "
+func foo() {
+ UIView.animateWithDuration(1.0,
+ animations: {
+ }
+ |) {
+ completed in
+ }
+}
")
(check-indentation indents-expression-with-optional-type/1
- [nongnu] elpa/swift-mode 8db040e 166/496: fix: underscores are word characters (Word constituents), (continued)
- [nongnu] elpa/swift-mode 8db040e 166/496: fix: underscores are word characters (Word constituents), ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 2a21e1b 177/496: Add ternary operator smie grammar, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 641681a 182/496: Fix small typo in comment string, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 2b17f71 183/496: Improve grammar and lexer to support access modifier in class definitions, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode cac2884 185/496: Add lists to the "type" grammar, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode adfe341 190/496: Add grammar for the protocol definitions, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 20134ed 193/496: Use postive lookahead for declaration specifier lexer rule, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode c2c3c01 199/496: Improve support for optional types, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode d6483e1 207/496: Add ?? to the lexer rule for operators, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 9e6c538 210/496: Correct DECSPEC regex and lexer rule, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 2c67d92 213/496: Fix indentation of the closure arguments inside parentheses,
ELPA Syncer <=
- [nongnu] elpa/swift-mode 5a858c7 218/496: Improve indentation of the array and dictionary expressions, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 195d040 227/496: Merge pull request #76 from ap4y/batch_smie_fixes, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode dbf48a1 232/496: Merge pull request #90 from nathankot/flycheck-framework-search-paths, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode e6f1a3c 237/496: More configurability for flycheck, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 3e8befa 238/496: Merge pull request #92 from apiology/more_flycheck_option_vars, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 31fb250 248/496: added elseguard to lexer, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 071cd18 249/496: Merge pull request #100 from uk-ar/enable-pairing-for-curly-bracket, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 7cefd8c 255/496: Fix token for generics, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode c51eaf8 257/496: Fix token for ! & ?, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode ce816a8 270/496: Fix backward-sexp test by adding brackets, ELPA Syncer, 2021/08/29