all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#63879: 29.0.90; [PATCH] Fix rust-ts-mode indentation for else-if
@ 2023-06-03 23:18 Yuan Fu
  2023-06-03 23:58 ` Randy Taylor
  0 siblings, 1 reply; 4+ messages in thread
From: Yuan Fu @ 2023-06-03 23:18 UTC (permalink / raw)
  To: 63879; +Cc: dev

[-- Attachment #1: Type: text/plain, Size: 130 bytes --]

X-Debbugs-CC: dev@rjt.dev

Example:

fn main() {
    if true {
        ()
    } else if true {
            ()
        }
}


Yuan


[-- Attachment #2: rust-ts-mode.patch --]
[-- Type: application/octet-stream, Size: 2081 bytes --]

From d412e7d597d15a94b6725e231f392518138cc550 Mon Sep 17 00:00:00 2001
From: Yuan Fu <casouri@gmail.com>
Date: Sat, 3 Jun 2023 16:13:05 -0700
Subject: [PATCH] Fix rust-ts-mode indentation for else-if

This change fixes the indentation for code like this:

fn main() {
    if true {
        ()
    } else if true {
        ()
    }
}

Before this change, the else-if's are indented one more level than it
should, because it's nested in the if node:

fn main() {
    if true {
        ()
    } else if true {
            ()
        }
}

* lisp/progmodes/rust-ts-mode.el (rust-ts-mode--indent-rules): Replace
parent-bol with standalone-parent.
---
 lisp/progmodes/rust-ts-mode.el | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lisp/progmodes/rust-ts-mode.el b/lisp/progmodes/rust-ts-mode.el
index be06acde3e3..ca295212640 100644
--- a/lisp/progmodes/rust-ts-mode.el
+++ b/lisp/progmodes/rust-ts-mode.el
@@ -74,7 +74,7 @@ rust-ts-mode--indent-rules
      ((parent-is "source_file") column-0 0)
      ((node-is ")") parent-bol 0)
      ((node-is "]") parent-bol 0)
-     ((node-is "}") (and parent parent-bol) 0)
+     ((node-is "}") (and parent standalone-parent) 0)
      ((and (parent-is "comment") c-ts-common-looking-at-star)
       c-ts-common-comment-start-after-first-star -1)
      ((parent-is "comment") prev-adaptive-prefix 0)
@@ -82,7 +82,7 @@ rust-ts-mode--indent-rules
      ((parent-is "await_expression") parent-bol rust-ts-mode-indent-offset)
      ((parent-is "array_expression") parent-bol rust-ts-mode-indent-offset)
      ((parent-is "binary_expression") parent-bol rust-ts-mode-indent-offset)
-     ((parent-is "block") parent-bol rust-ts-mode-indent-offset)
+     ((parent-is "block") standalone-parent rust-ts-mode-indent-offset)
      ((parent-is "declaration_list") parent-bol rust-ts-mode-indent-offset)
      ((parent-is "enum_variant_list") parent-bol rust-ts-mode-indent-offset)
      ((parent-is "field_declaration_list") parent-bol rust-ts-mode-indent-offset)
-- 
2.33.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-06-05  7:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-03 23:18 bug#63879: 29.0.90; [PATCH] Fix rust-ts-mode indentation for else-if Yuan Fu
2023-06-03 23:58 ` Randy Taylor
2023-06-04  5:12   ` Eli Zaretskii
2023-06-05  7:43     ` Yuan Fu

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.