emacs-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#67488: closed ([PATCH] Fix typescript-ts-mode indentation for switch


From: GNU bug Tracking System
Subject: bug#67488: closed ([PATCH] Fix typescript-ts-mode indentation for switch statements)
Date: Wed, 29 Nov 2023 14:36:02 +0000

Your message dated Wed, 29 Nov 2023 16:35:06 +0200
with message-id <835y1k7hlx.fsf@gnu.org>
and subject line Re: bug#67488: [PATCH] Fix typescript-ts-mode indentation for 
switch statements
has caused the debbugs.gnu.org bug report #67488,
regarding [PATCH] Fix typescript-ts-mode indentation for switch statements
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs@gnu.org.)


-- 
67488: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=67488
GNU Bug Tracking System
Contact help-debbugs@gnu.org with problems
--- Begin Message --- Subject: [PATCH] Fix typescript-ts-mode indentation for switch statements Date: Mon, 27 Nov 2023 09:07:51 -0800
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'

Attachment: typescript-ts-mode-switch-indentation.patch
Description: Text Data


--- End Message ---
--- Begin Message --- Subject: Re: bug#67488: [PATCH] Fix typescript-ts-mode indentation for switch statements Date: Wed, 29 Nov 2023 16:35:06 +0200
> Cc: theo@thornhill.no
> Date: Mon, 27 Nov 2023 21:53:49 -0800
> From: Yuan Fu <casouri@gmail.com>
> 
> > 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.

Thanks, installed on the emacs-29 branch and closing the bug.


--- End Message ---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]