From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Noah Peart Newsgroups: gmane.emacs.bugs Subject: bug#67488: [PATCH] Fix typescript-ts-mode indentation for switch statements Date: Mon, 27 Nov 2023 09:07:51 -0800 Message-ID: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="00000000000044208f060b255897" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="4781"; mail-complaints-to="usenet@ciao.gmane.io" To: 67488@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Nov 27 18:12:00 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1r7f9M-00012h-Fx for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 27 Nov 2023 18:12:00 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r7f6R-0007iB-2H; Mon, 27 Nov 2023 12:08:59 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r7f6P-0007hQ-FF for bug-gnu-emacs@gnu.org; Mon, 27 Nov 2023 12:08:57 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r7f6P-0004fa-16 for bug-gnu-emacs@gnu.org; Mon, 27 Nov 2023 12:08:57 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1r7f6U-0005ib-5r for bug-gnu-emacs@gnu.org; Mon, 27 Nov 2023 12:09:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Noah Peart Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 27 Nov 2023 17:09:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 67488 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.170110490821936 (code B ref -1); Mon, 27 Nov 2023 17:09:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 27 Nov 2023 17:08:28 +0000 Original-Received: from localhost ([127.0.0.1]:44665 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r7f5v-0005hk-Av for submit@debbugs.gnu.org; Mon, 27 Nov 2023 12:08:27 -0500 Original-Received: from lists.gnu.org ([2001:470:142::17]:32816) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r7f5u-0005hK-07 for submit@debbugs.gnu.org; Mon, 27 Nov 2023 12:08:26 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r7f5h-0007Ld-LF for bug-gnu-emacs@gnu.org; Mon, 27 Nov 2023 12:08:13 -0500 Original-Received: from mail-oa1-x2c.google.com ([2001:4860:4864:20::2c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r7f5b-0004ZQ-LH for bug-gnu-emacs@gnu.org; Mon, 27 Nov 2023 12:08:13 -0500 Original-Received: by mail-oa1-x2c.google.com with SMTP id 586e51a60fabf-1efabc436e4so3007004fac.1 for ; Mon, 27 Nov 2023 09:08:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701104883; x=1701709683; darn=gnu.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=EdC/TM4m8hiSO+g/4kgaQ8aDbdIx+f1KSzpYDiFfdOU=; b=P4WSVGlfTWhmeDuqy1AiV0lb2Ggt/fhDkMsKBeAMJG/mQ2fDQxDrDzTSsz2diAVAx/ CTPTWCASbpdBgOiqJ+7PE2jsKZDn7S4DwAB+aizn8DH/MDyaSVPhXZ9M7x8e2bA/WQU2 eVKKKDIZVv4Yinkef1L14xyeoEBoNeQcZd3oDi8AW4u5nYQIzY0h0Xr/8Yx2qGPwkCHH JTcT3F+Va/tGvO95YO+YgNavTmWoSmKmzxNkwE0qsPGbY2YZDIfz8aRtJr07nGUGIZPX xMv7NdvigGVSOVHfKN7XaaH8/P8HqkQrE9M+XO00qEgw5P+aR0uVpa6WEG4D+bjt57fQ EXqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701104883; x=1701709683; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=EdC/TM4m8hiSO+g/4kgaQ8aDbdIx+f1KSzpYDiFfdOU=; b=blEghT76oRthfgwO5bwCrwVydPbA/VF1Q1T8th3v6sxrr4q8/bDvjXCx+gT8kxyrgw byH52z+q0gxGkX5b6iGGajZaj/c0l4vH/eJ9w+VfwmFGNVO2WKWVOHkVWu70YeXXSlTl tMZG+gfIsRDp99yg+P6/Tg6EZJyAzJQPxnsG8NYygMpvdE2ECG9znZ54+KOTluAkjfTQ NEORVU45MTFNCEzJUTgvbYuQorf5iDlkn8J1AbFXNIo5OaSMoRiVLm7izEI8XJztUQiY RCczMFLWHjkuDl+1y2aWlXjl3TUUXjgSj6VZA5yOgmvMUImEckHDRYKySKyJp11CZ8ep cFKg== X-Gm-Message-State: AOJu0YxQVP7jbrS1hj4N/vDQkRnJKUDGw6n/mHTpu/Ff+11vpQ5QeiDm 2louts9/Fv8e7Y1IVKNDoVojz8LaLItTa3vPM50Dp1L1uxwh9bL5 X-Google-Smtp-Source: AGHT+IEpisNZZEyfrdRSMNWlLoZl9oXMOXTRqcwp6n6KwmVR+IIOYSqx/G+dCo/BFxU9PQzUC5HWovRoX1uTOg6xuqE= X-Received: by 2002:a05:6871:e499:b0:1fa:345e:5e14 with SMTP id pz25-20020a056871e49900b001fa345e5e14mr9498338oac.36.1701104882812; Mon, 27 Nov 2023 09:08:02 -0800 (PST) Received-SPF: pass client-ip=2001:4860:4864:20::2c; envelope-from=noah.v.peart@gmail.com; helo=mail-oa1-x2c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:275138 Archived-At: --00000000000044208f060b255897 Content-Type: multipart/alternative; boundary="00000000000044208e060b255895" --00000000000044208e060b255895 Content-Type: text/plain; charset="UTF-8" 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. In GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.33, cairo version 1.16.0) of 2023-11-27 built on noah-X580VD Repository revision: 76cf700ecb78cb465bcd05ae2b2fb0d28e4d0aed Repository branch: master Windowing system distributor 'The X.Org Foundation', version 11.0.12101004 System Description: Ubuntu 22.04.3 LTS Configured using: 'configure --prefix=/usr/local --with-modules --with-tree-sitter --with-threads --with-x-toolkit=gtk3 --with-xwidgets --with-gnutls --with-json --with-mailutils --with-jpeg --with-png --with-rsvg --with-tiff --with-xml2 --with-xpm --with-imagemagick CC=gcc-12 CXX=gcc-12' --00000000000044208e060b255895 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Tags: patch

* lisp/progmodes/typescript-ts-mode.el(= typescript-ts-mode): Add indentation
rule for switch case and default ke= ywords.

Bug: `typescript-ts-mode` is missing indentation rules for &= #39;case' and
'default' keywords in switch statements.
Recipe to reproduce:
Copy the following code into a buffer:

=C2= =A0 =C2=A0 const foo =3D (x: string) =3D> {
=C2=A0 =C2=A0 =C2=A0 swit= ch (x) {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = case "a":
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 console.log(x);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 return 1;
=C2=A0 =C2=A0 case "b":
=C2=A0 = =C2=A0 =C2=A0 return 2;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 case "c":
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 default:
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return 0;
=C2=A0 =C2=A0 =C2=A0 }
= =C2=A0 =C2=A0 };

And call the following function to configure typesc= ript-ts-mode and
indent the buffer

=C2=A0 =C2=A0 (defun my-ts-ind= entation ()
=C2=A0 =C2=A0 =C2=A0 (interactive)
=C2=A0 =C2=A0 =C2=A0 (= setq indent-tabs-mode nil)
=C2=A0 =C2=A0 =C2=A0 (setq typescript-ts-mode= -indent-offset 2)
=C2=A0 =C2=A0 =C2=A0 (typescript-ts-mode)
=C2=A0 = =C2=A0 =C2=A0 (indent-region (point-min) (point-max)))

The indentati= on for the 'case' and 'default' branches within the switch<= br>statement should still be unchanged due to missing indent rules.
Bug= applies to emacs 29 as well.


In GNU Emacs 30.0.50 (build 1, x86= _64-pc-linux-gnu, GTK+ Version
3.24.33, cairo version 1.16.0) of 2023-11= -27 built on noah-X580VD
Repository revision: 76cf700ecb78cb465bcd05ae2b= 2fb0d28e4d0aed
Repository branch: master
Windowing system distributor= 'The X.Org Foundation', version 11.0.12101004
System Descriptio= n: Ubuntu 22.04.3 LTS

Configured using:
=C2=A0'configure --pr= efix=3D/usr/local --with-modules --with-tree-sitter
--with-threads --wit= h-x-toolkit=3Dgtk3 --with-xwidgets --with-gnutls
--with-json --with-mail= utils --with-jpeg --with-png --with-rsvg
--with-tiff --with-xml2 --with-= xpm --with-imagemagick CC=3Dgcc-12
CXX=3Dgcc-12'
--00000000000044208e060b255895-- --00000000000044208f060b255897 Content-Type: text/x-patch; charset="US-ASCII"; name="typescript-ts-mode-switch-indentation.patch" Content-Disposition: attachment; filename="typescript-ts-mode-switch-indentation.patch" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_lph5votp0 RnJvbSA5N2NiYWUzOTU2MjIzM2E2ZWI5ZjIzOTNhZDY1NTZiODQwOWE3ZWFhIE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBudmVybm8gPG5vYWgudi5wZWFydEBnbWFpbC5jb20+CkRhdGU6 IE1vbiwgMjcgTm92IDIwMjMgMDg6NTU6MjMgLTA4MDAKU3ViamVjdDogW1BBVENIXSBGaXggdHlw ZXNjcmlwdC10cy1tb2RlIGluZGVudGF0aW9uIGZvciBzd2l0Y2ggc3RhdGVtZW50cwoKKiBsaXNw L3Byb2dtb2Rlcy90eXBlc2NyaXB0LXRzLW1vZGUuZWwodHlwZXNjcmlwdC10cy1tb2RlKTogQWRk IGluZGVudGF0aW9uCnJ1bGUgZm9yIHN3aXRjaCBjYXNlIGFuZCBkZWZhdWx0IGtleXdvcmRzLgot LS0KIGxpc3AvcHJvZ21vZGVzL3R5cGVzY3JpcHQtdHMtbW9kZS5lbCAgICAgICAgICAgIHwgIDMg KysrCiAuLi4vdHlwZXNjcmlwdC10cy1tb2RlLXJlc291cmNlcy9pbmRlbnQuZXJ0cyAgICB8IDE3 ICsrKysrKysrKysrKysrKysrCiAyIGZpbGVzIGNoYW5nZWQsIDIwIGluc2VydGlvbnMoKykKCmRp ZmYgLS1naXQgYS9saXNwL3Byb2dtb2Rlcy90eXBlc2NyaXB0LXRzLW1vZGUuZWwgYi9saXNwL3By b2dtb2Rlcy90eXBlc2NyaXB0LXRzLW1vZGUuZWwKaW5kZXggMDUwM2M3MjRkMzYuLjc5OThiMzc0 MGI2IDEwMDY0NAotLS0gYS9saXNwL3Byb2dtb2Rlcy90eXBlc2NyaXB0LXRzLW1vZGUuZWwKKysr IGIvbGlzcC9wcm9nbW9kZXMvdHlwZXNjcm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mNDIzMjU5YjQuLjdiNjE4NWUw Mzg2IDEwMDY0NAotLS0gYS90ZXN0L2xpc3AvcHJvZ21vZGVzL3R5cGVzY3JpcHQtdHMtbW9kZS1y ZXNvdXJjZXMvaW5kZW50LmVydHMKKysrIGIvdGVzdC9saXNwL3Byb2dtb2Rlcy90eXBlc2NyaXB0 LXRzLW1vZGUtcmVzb3VyY2VzL2luZGVudC5lcnRzCkBAIC00NSw2ICs0NSwyMyBAQCBjb25zdCBm b28gPSAoKSA9PiB7CiB9OwogPS09LT0KIAorTmFtZTogU3dpdGNoIHN0YXRlbWVudAorCis9LT0K K2NvbnN0IGZvbyA9ICh4OiBzdHJpbmcpID0+IHsKKyAgc3dpdGNoICh4KSB7CisgICAgY2FzZSAi YSI6CisgICAgICBjb25zb2xlLmxvZyh4KTsKKyAgICAgIHJldHVybiAxOworICAgIGNhc2UgImIi OgorICAgICAgcmV0dXJuIDI7CisgICAgY2FzZSAiYyI6CisgICAgZGVmYXVsdDoKKyAgICAgIHJl dHVybiAwOworICB9Cit9OworPS09LT0KKwogQ29kZToKICAgKGxhbWJkYSAoKQogICAgIChzZXRx IGluZGVudC10YWJzLW1vZGUgbmlsKQotLSAKMi4zNC4xCgo= --00000000000044208f060b255897--