From 421ecbcf6b476c413675e93c074f1399db146fc8 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Sun, 25 May 2025 12:08:02 +0300 Subject: [PATCH 1/2] ; * CONTRIBUTE: Explain the line-width preferences. --- CONTRIBUTE | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTE b/CONTRIBUTE index 06e6fe45c84..2da47fa35f8 100644 --- a/CONTRIBUTE +++ b/CONTRIBUTE @@ -231,7 +231,9 @@ formatting them: - Lines in ChangeLog entries should preferably be not longer than 63 characters, and must not exceed 78 characters, unless they consist of a single word of at most 140 characters; this 78/140 limit is - enforced by a commit hook. + enforced by a commit hook. (The 63-character preference is to + avoid too-long lines in the ChangeLog file generated from Git logs, + where each entry line is indented by a TAB.) - If only a single file is changed, the summary line can be the normal first line of a ChangeLog entry (starting with the asterisk). Then From 1d2ae31b8bcca5f00c3c707cc7af3a347749c332 Mon Sep 17 00:00:00 2001 From: Konstantin Kharlamov Date: Tue, 29 Apr 2025 21:51:18 +0700 Subject: [PATCH 2/2] typescript-ts-mode: Improve function body indentation (bug#78121) Older code was calculating body indentation depending on function parameters alignment. This is incorrect, because if parameters are misaligned, so will the function body. Instead, use offset of the previous standalone parent. * lisp/progmodes/typescript-ts-mode.el: (typescript-ts-mode--indent-rules): Stop depending on function parameters indentation for calculating body content and the closing `}'. * test/lisp/progmodes/typescript-ts-mode-resources/indent.erts: (Function body with params misindented (bug#78121)): Add new test. --- lisp/progmodes/typescript-ts-mode.el | 4 +-- .../typescript-ts-mode-resources/indent.erts | 25 +++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/lisp/progmodes/typescript-ts-mode.el b/lisp/progmodes/typescript-ts-mode.el index 6cc1eb0bea9..72b9d31204c 100644 --- a/lisp/progmodes/typescript-ts-mode.el +++ b/lisp/progmodes/typescript-ts-mode.el @@ -111,7 +111,7 @@ declarations, accounting for the length of keyword (var, let, or const)." Argument LANGUAGE is either `typescript' or `tsx'." `((,language ((parent-is "program") column-0 0) - ((node-is "}") parent-bol 0) + ((node-is "}") standalone-parent 0) ((node-is ")") parent-bol 0) ((node-is "]") parent-bol 0) ((node-is ">") parent-bol 0) @@ -121,7 +121,7 @@ Argument LANGUAGE is either `typescript' or `tsx'." ((parent-is "ternary_expression") standalone-parent typescript-ts-mode-indent-offset) ((parent-is "member_expression") parent-bol typescript-ts-mode-indent-offset) ((parent-is "named_imports") parent-bol typescript-ts-mode-indent-offset) - ((parent-is "statement_block") parent-bol typescript-ts-mode-indent-offset) + ((parent-is "statement_block") standalone-parent typescript-ts-mode-indent-offset) ((or (node-is "case") (node-is "default")) parent-bol typescript-ts-mode-indent-offset) diff --git a/test/lisp/progmodes/typescript-ts-mode-resources/indent.erts b/test/lisp/progmodes/typescript-ts-mode-resources/indent.erts index 8abaa81c627..405566c40f0 100644 --- a/test/lisp/progmodes/typescript-ts-mode-resources/indent.erts +++ b/test/lisp/progmodes/typescript-ts-mode-resources/indent.erts @@ -164,3 +164,28 @@ interface Foo { bar?: boolean; } =-=-= + +Code: + (lambda () + (setq tsx-ts-mode-indent-offset 2) + (tsx-ts-mode) + (setq indent-tabs-mode nil) + (indent-region (line-beginning-position 7) (point-max))) + +Name: Function body with params misindented (bug#78121) + +=-= +const f1 = (a1: string, + a2: number) => { + const f2 = (a1: string, + a2: number) => { + const f3 = (a1: string, + a2: number) => + { + return; + } + return; + } + return; +} +=-=-=