From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#61053: 29.0.60; typescript-ts-mode does not correctly highlight function-valued variables. [PATCH] Date: Wed, 25 Jan 2023 15:05:58 +0200 Message-ID: <83sffyg3wp.fsf@gnu.org> References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="20795"; mail-complaints-to="usenet@ciao.gmane.io" Cc: theo@thornhill.no, 61053@debbugs.gnu.org To: jostein@kjonigsen.net Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Jan 25 14:06:13 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 1pKfTh-0005Du-BG for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 25 Jan 2023 14:06:13 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pKfTZ-0007mL-Od; Wed, 25 Jan 2023 08:06:05 -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 1pKfTX-0007lm-7S for bug-gnu-emacs@gnu.org; Wed, 25 Jan 2023 08:06:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pKfTW-00007c-Of for bug-gnu-emacs@gnu.org; Wed, 25 Jan 2023 08:06:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pKfTW-0007Fs-7z for bug-gnu-emacs@gnu.org; Wed, 25 Jan 2023 08:06:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 25 Jan 2023 13:06:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 61053 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 61053-submit@debbugs.gnu.org id=B61053.167465195427872 (code B ref 61053); Wed, 25 Jan 2023 13:06:02 +0000 Original-Received: (at 61053) by debbugs.gnu.org; 25 Jan 2023 13:05:54 +0000 Original-Received: from localhost ([127.0.0.1]:58583 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pKfTN-0007FT-Ib for submit@debbugs.gnu.org; Wed, 25 Jan 2023 08:05:53 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:44482) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pKfTK-0007F9-PG for 61053@debbugs.gnu.org; Wed, 25 Jan 2023 08:05:52 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pKfTE-0008S5-Q2; Wed, 25 Jan 2023 08:05:44 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=n5cNnh9zkei9/NDcExCm1E0FN99JNRNKfjjzqwHxiWs=; b=KVsQ9GcElHlzDPpMssY8 3z/kbIKlJJ2OdM2r2eCa4F+gja2HTEwXKr/EbrghYqytgVGceVyozPEoAmhlCEObzbDg8eTF6FIBB wdFe+QXtbuJD6ZOJbY9GBbyOO14ScPP6q7LIL6l8nSCHLP013jW4GKkvjYVrv20Xv7aA/NbRgYd5w 3ykvkam6KQ4/Us3Wu4sCpxpU9bdJPhJdOAFFA0uACD0SsH4UkKQJIKviefsqOfTrlQTvHHNaWp+rp BOA3RwMQY8MdHemVwKGXLVL5p1tdjDDcBZx6bXi+sRJbu88ab5EpZ7DqzLXkdDA02j+az47M0m3s0 YY9lJS+va6N6XA==; Original-Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pKfTE-0007rT-9i; Wed, 25 Jan 2023 08:05:44 -0500 In-Reply-To: (message from Jostein =?UTF-8?Q?Kj=C3=B8nigsen?= on Wed, 25 Jan 2023 10:41:23 +0100) 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:254121 Archived-At: > Cc: Theodor Thornhill > Date: Wed, 25 Jan 2023 10:41:23 +0100 > From: Jostein Kjønigsen > > When working with codebases where people define functions by assigned arrow-expressions to local > variables, typescript-ts-mode (and tsx-ts-mode) currently does not highlight them as function declarations. > > // this works > function demoFunction() { > } > > // this doesnt > const demoFunction = () => { > }; > > We actually have a selector for this, but it is not getting triggered, because of what looks like ordering > issues. > > We also have override :t for almost every single feature in this mode, making it hard to know how selectors > gets applied. > > Attached is a patch whic: > > 1. reorders selectors to correctly highlight function-declaration (required change, but not sufficient) > 2. disables override everywhere, except for declaration, in order to keep fontification correct. Thanks. When fixing such "tricky" issues, please always include in the code comments which explain the tricky stuff, in this case why some code must be before the other. Otherwise we run the risk that someone, some day, will reorder the code, and we get the bug back. Adding tests for this is even better (but doesn't make the comments less important).