From: Yuan Fu <casouri@gmail.com>
To: 67488@debbugs.gnu.org
Cc: theo@thornhill.no
Subject: bug#67488: [PATCH] Fix typescript-ts-mode indentation for switch statements
Date: Mon, 27 Nov 2023 21:53:49 -0800 [thread overview]
Message-ID: <249b56d1-1345-4b59-98c7-3f019564fa82@gmail.com> (raw)
In-Reply-To: <3420a38f-6ae7-fd20-28d8-e4815c8fa3cc@gutov.dev>
On 11/27/23 4:39 PM, Dmitry Gutov wrote:
> On 27/11/2023 19:07, Noah Peart wrote:
>> Tags: patch
>>
>> * lisp/progmodes/typescript-ts-mode.el(typescript-ts-mode): Add
>> indentation
>> rule for switch case and default keywords.
>>
>> Bug: `typescript-ts-mode` is missing indentation rules for 'case' and
>> 'default' keywords in switch statements.
>>
>> Recipe to reproduce:
>> Copy the following code into a buffer:
>>
>> const foo = (x: string) => {
>> switch (x) {
>> case "a":
>> console.log(x);
>> return 1;
>> case "b":
>> return 2;
>> case "c":
>> default:
>> return 0;
>> }
>> };
>>
>> And call the following function to configure typescript-ts-mode and
>> indent the buffer
>>
>> (defun my-ts-indentation ()
>> (interactive)
>> (setq indent-tabs-mode nil)
>> (setq typescript-ts-mode-indent-offset 2)
>> (typescript-ts-mode)
>> (indent-region (point-min) (point-max)))
>>
>> The indentation for the 'case' and 'default' branches within the switch
>> statement should still be unchanged due to missing indent rules.
>> Bug applies to emacs 29 as well.
>
> Thanks! Can repro. The fix looks good as well.
>
LGTM. The only thing I'll add is that you can probably use a single
regular expression rather than using the "or" matcher. But that's
largely personal preference.
Yuan
next prev parent reply other threads:[~2023-11-28 5:53 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-27 17:07 bug#67488: [PATCH] Fix typescript-ts-mode indentation for switch statements Noah Peart
2023-11-28 0:39 ` Dmitry Gutov
2023-11-28 5:53 ` Yuan Fu [this message]
2023-11-29 14:35 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=249b56d1-1345-4b59-98c7-3f019564fa82@gmail.com \
--to=casouri@gmail.com \
--cc=67488@debbugs.gnu.org \
--cc=theo@thornhill.no \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).