GNU bug report logs - #80038
[PATCH] 31.0.50; csharp-ts-mode: Fontification of caught exceptions is incorrect

Previous Next

Package: emacs;

Reported by: Jostein Kjønigsen <jostein <at> secure.kjonigsen.net>

Date: Fri, 19 Dec 2025 20:51:02 UTC

Severity: normal

Tags: patch

Done: Eli Zaretskii <eliz <at> gnu.org>

To reply to this bug, email your comments to 80038 AT debbugs.gnu.org.
There is no need to reopen the bug first.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#80038; Package emacs. (Fri, 19 Dec 2025 20:51:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Jostein Kjønigsen <jostein <at> secure.kjonigsen.net>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Fri, 19 Dec 2025 20:51:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Jostein Kjønigsen <jostein <at> secure.kjonigsen.net>
To: bug-gnu-emacs <at> gnu.org
Cc: Yuan Fu <casouri <at> gmail.com>, Theodor Thornhill <theo <at> thornhill.no>
Subject: [PATCH] 31.0.50; csharp-ts-mode: Fontification of caught exceptions
 is incorrect
Date: Fri, 19 Dec 2025 21:50:12 +0100
[Message part 1 (text/plain, inline)]
Hey there!

When you create a basic try/catch expression in C# using csharp-ts-mode
it gets fontified incorrectly.

Example:

try
{
   // buggy code
}
catch (Exception ex)
{
   // other code
}

In this case "Exception" will be fontified using
font-lock-type-face. This is correct.

However "ex" is also fontified as font-lock-type-face. This is
incorrect. It should be fontifified as font-lock-variable-name-face.

Attached is a patch which fixes this.




In GNU Emacs 31.0.50 (build 1, aarch64-apple-darwin24.6.0, NS
 appkit-2575.70 Version 15.7.1 (Build 24G231)) of 2025-11-06 built on
 SOK67R3KWV97
Repository revision: eea3e3ff594f93dcbf6fa3900ec55cec0ba6fbbf
Repository branch: master
Windowing system distributor 'Apple', version 10.3.2575
System Description:  macOS 15.7.2

Configured using:
 'configure --with-json --with-tree-sitter --with-native-compilation
 PKG_CONFIG_PATH=:/usr/local/lib/pkgconfig:/opt/local/lib/pkgconfig'

Configured features:
ACL GLIB GNUTLS LCMS2 LIBXML2 MODULES NATIVE_COMP NOTIFY KQUEUE NS
PDUMPER PNG RSVG SQLITE3 THREADS TOOLKIT_SCROLL_BARS TREE_SITTER WEBP
XIM ZLIB

Important settings:
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Fundamental

Minor modes in effect:
  treemacs-filewatch-mode: t
  treemacs-follow-mode: t
  treemacs-git-mode: t
  treemacs-fringe-indicator-mode: t
  global-git-commit-mode: t
  magit-auto-revert-mode: t
  delete-selection-mode: t
  global-auto-revert-mode: t
  editorconfig-mode: t
  all-the-icons-completion-mode: t
  marginalia-mode: t
  vertico-mode: t
  global-nlinum-mode: t
  nlinum-mode: t
  override-global-mode: t
  server-mode: t
  global-hl-line-mode: t
  pixel-scroll-precision-mode: t
  doom-modeline-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  minibuffer-nonselected-mode: t
  minibuffer-regexp-mode: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug lisp-mnt magit-gitignore lua-ts-mode po
typescript-ts-mode js treemacs-mouse-interface treemacs
treemacs-header-line treemacs-compatibility treemacs-mode
treemacs-bookmarks treemacs-tags treemacs-interface treemacs-persistence
treemacs-filewatch-mode treemacs-follow-mode treemacs-rendering
treemacs-annotations treemacs-async treemacs-workspaces treemacs-dom
treemacs-visuals treemacs-fringe-indicator treemacs-faces treemacs-icons
treemacs-scope treemacs-themes treemacs-core-utils pfuture ht
treemacs-logging treemacs-customization treemacs-macros make-mode
toml-ts-mode shr-color textsec uni-scripts idna-mapping uni-confusable
textsec-check rng-xsd xsd-regexp rng-cmpct rng-nxml rng-valid rng-loc
rng-uri rng-parse nxml-parse rng-match rng-dt rng-util rng-pttrn nxml-ns
nxml-mode nxml-outln nxml-rap nxml-util nxml-enc xmltok pet yaml
let-alist ring-bell-fns conf-mode yaml-ts-mode whitespace tramp-sh
shortdoc git-rebase find-dired grep dired-aux all-the-icons-dired
consult-imenu goto-addr macros json-ts-mode misearch multi-isearch
powershell ido help-fns radix-tree bicep-ts-mode network-stream url-http
url-gw nsm url-cache url-auth markdown-mode magit-extras vc-hg vc-bzr
vc-src vc-sccs vc-svn vc-cvs vc-rcs log-view vc bug-reference
magit-bookmark magit-submodule magit-blame magit-stash magit-reflog
magit-bisect magit-push magit-pull magit-fetch magit-clone magit-remote
magit-commit magit-sequence magit-notes magit-worktree magit-tag
magit-merge magit-branch magit-reset magit-files magit-refs magit-status
magit magit-repos magit-apply magit-wip magit-log which-func magit-diff
smerge-mode git-commit log-edit pcvs-util add-log magit-core
magit-autorevert magit-margin magit-transient magit-process with-editor
magit-mode benchmark magit-git magit-base magit-section cursor-sensor
crm llama cond-let pulse elec-pair csharp-mode c-ts-common cc-langs
cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine
cc-vars cc-defs vc-git vc-dispatcher vertico-sort org-duration diary-lib
diary-loaddefs cal-iso disp-table oc-basic ol-eww ol-rmail ol-mhe ol-irc
ol-info ol-gnus nnselect gnus-art mm-uu mml2015 mm-view mml-smime smime
gnutls dig gnus-sum gnus-group gnus-undo gnus-start gnus-dbus dbus
gnus-cloud nnimap nnmail mail-source utf7 nnoo gnus-spec gnus-int
gnus-range message sendmail yank-media rfc822 mml mml-sec epa derived
epg rfc6068 epg-config mm-decode mm-bodies mm-encode mail-parse rfc2231
rfc2047 rfc2045 ietf-drums mailabbrev gmm-utils mailheader gnus-win
ol-docview doc-view jka-compr image-mode exif dired dired-loaddefs
ol-bibtex bibtex ol-bbdb ol-w3m ol-doi org-link-doi org-agenda
elisp-slime-nav etags fileloop semel scope paredit highlight-symbol
flycheck indent-bars-ts indent-bars cus-edit cus-start cus-load
face-remap color eglot external-completion jsonrpc flymake diff ert ewoc
debug backtrace compile completion-preview hideshow eww vtable url-queue
shr pixel-fill kinsoku url-file svg xml puny mm-url gnus nnheader
gnus-util mail-utils range mm-util mail-prsvr tramp-cache time-stamp
tramp trampver tramp-integration tramp-message tramp-compat shell
parse-time iso8601 tramp-loaddefs imenu ob-plantuml delsel autorevert
filenotify embark-org org-element org-persist org-id org-refile
org-element-ast inline avl-tree org ob ob-tangle ob-ref ob-lob ob-table
ob-exp org-macro org-src sh-script smie executable ob-comint
org-pcomplete pcomplete org-list org-footnote org-faces org-entities
time-date noutline outline ob-emacs-lisp ob-core ob-eval org-cycle
org-table ol org-fold org-fold-core org-keys oc org-loaddefs find-func
cal-menu calendar cal-loaddefs org-version org-compat org-macs
editorconfig editorconfig-core editorconfig-core-handle
editorconfig-fnmatch embark-consult consult bookmark
text-property-search embark ffap orderless all-the-icons-completion
marginalia vertico nlinum linum use-package-bind-key bind-key recentf
tree-widget wid-edit server hl-line pixel-scroll cua-base all-the-icons
all-the-icons-faces data-material data-weathericons data-octicons
data-fileicons data-faicons data-alltheicons doom-modeline
doom-modeline-segments doom-modeline-env doom-modeline-core shrink-path
f s dash nerd-icons nerd-icons-faces nerd-icons-data
nerd-icons-data-mdicon nerd-icons-data-flicon nerd-icons-data-codicon
nerd-icons-data-devicon nerd-icons-data-sucicon nerd-icons-data-wicon
nerd-icons-data-faicon nerd-icons-data-powerline nerd-icons-data-octicon
nerd-icons-data-pomicon nerd-icons-data-ipsicon dracula-theme
exec-path-from-shell use-package-ensure use-package-core finder-inf
all-the-icons-completion-autoloads all-the-icons-dired-autoloads
all-the-icons-autoloads bmx-mode-autoloads cargo-autoloads
cmake-mode-autoloads combobulate-autoloads combobulate-go
combobulate-json combobulate-yaml combobulate-css combobulate-js-ts
combobulate-python combobulate-html combobulate-toml combobulate-cursor
multiple-cursors mc-separate-operations rectangular-region-mode
mc-mark-pop mc-edit-lines mc-hide-unmatched-lines-mode mc-mark-more
sgml-mode facemenu dom thingatpt mc-cycle-cursors multiple-cursors-core
advice comp comp-cstr cl-extra help-mode warnings comp-run comp-common
rect combobulate-query savehist xref files-x scheme combobulate-ui
transient pp format-spec edmacro kmacro combobulate-display
combobulate-ztree combobulate-envelope combobulate-manipulation python
rx project compat comint ansi-osc ring ansi-color combobulate-procedure
combobulate-navigation combobulate-misc combobulate-setup tempo
combobulate-interface combobulate-settings diff-mode track-changes
easy-mmode treesit generator combobulate-rules company-autoloads
copilot-mode-autoloads crontab-mode-autoloads dap-mode-autoloads
bui-autoloads doom-modeline-autoloads dracula-theme-autoloads
elisp-slime-nav-autoloads embark-consult-autoloads consult-autoloads
embark-autoloads exec-path-from-shell-autoloads expand-region-autoloads
flycheck-autoloads graphviz-dot-mode-autoloads
highlight-symbol-autoloads indent-bars-autoloads lsp-docker-autoloads
lsp-treemacs-autoloads lsp-mode-autoloads magit-autoloads pcase
magit-section-autoloads llama-autoloads cond-let-autoloads
marginalia-autoloads markdown-mode-autoloads multiple-cursors-autoloads
nerd-icons-autoloads nlinum-autoloads orderless-autoloads
paredit-autoloads pet-autoloads powershell-autoloads semel-autoloads
shrink-path-autoloads f-autoloads spinner-autoloads swift-mode-autoloads
swift-ts-mode-autoloads treemacs-autoloads cfrs-autoloads
posframe-autoloads ht-autoloads hydra-autoloads lv-autoloads
pfuture-autoloads ace-window-autoloads avy-autoloads s-autoloads
dash-autoloads undo-tree-autoloads queue-autoloads vertico-autoloads
wgrep-autoloads info with-editor-autoloads wsd-mode-autoloads
yaml-autoloads package browse-url xdg url url-proxy url-privacy
url-expand url-methods url-history url-cookie generate-lisp-file
url-domsuf url-util mailcap url-handlers url-parse auth-source cl-seq
eieio eieio-core cl-macs icons password-cache json subr-x map byte-opt
gv bytecomp byte-compile url-vars cl-loaddefs cl-lib rmc iso-transl
tooltip cconv eldoc paren electric uniquify ediff-hook vc-hooks
lisp-float-type elisp-mode mwheel term/ns-win ns-win ucs-normalize
mule-util term/common-win tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode lisp-mode prog-mode register
page tab-bar menu-bar rfn-eshadow isearch easymenu timer select
scroll-bar mouse jit-lock font-lock syntax font-core term/tty-colors
frame minibuffer nadvice seq simple cl-generic indonesian philippine
cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao
korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech
european ethiopic indian cyrillic chinese composite emoji-zwj charscript
charprop case-table epa-hook jka-cmpr-hook help abbrev obarray oclosure
cl-preloaded button loaddefs theme-loaddefs faces cus-face macroexp
files window text-properties overlay sha1 md5 base64 format env
code-pages mule custom widget keymap hashtable-print-readable backquote
threads kqueue cocoa ns lcms2 multi-tty make-network-process
tty-child-frames native-compile emacs)

Memory information:
((conses 16 2327596 358450) (symbols 48 67734 122)
 (strings 32 413133 25455) (string-bytes 1 13477463)
 (vectors 16 133325) (vector-slots 8 2412992 386532)
 (floats 8 6041 45674) (intervals 56 188528 10544) (buffers 1064 189))



—
Kind Regards
Jostein Kjønigsen

[Message part 2 (text/html, inline)]
[0001-csharp-mode-Fix-fontification-of-catch-expressions.patch (application/octet-stream, attachment)]
[Message part 4 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#80038; Package emacs. (Sat, 20 Dec 2025 09:02:02 GMT) Full text and rfc822 format available.

Message #8 received at 80038 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Jostein Kjønigsen <jostein <at> secure.kjonigsen.net>
Cc: casouri <at> gmail.com, theo <at> thornhill.no, 80038 <at> debbugs.gnu.org
Subject: Re: bug#80038: [PATCH] 31.0.50;
 csharp-ts-mode: Fontification of caught exceptions is incorrect
Date: Sat, 20 Dec 2025 11:00:52 +0200
> Cc: Yuan Fu <casouri <at> gmail.com>, Theodor Thornhill <theo <at> thornhill.no>
> From: Jostein Kjønigsen <jostein <at> secure.kjonigsen.net>
> Date: Fri, 19 Dec 2025 21:50:12 +0100
> 
> When you create a basic try/catch expression in C# using csharp-ts-mode
> it gets fontified incorrectly.
> 
> Example:
> 
> try
> {
>    // buggy code
> }
> catch (Exception ex)
> {
>    // other code
> }
> 
> In this case "Exception" will be fontified using
> font-lock-type-face. This is correct.
> 
> However "ex" is also fontified as font-lock-type-face. This is
> incorrect. It should be fontifified as font-lock-variable-name-face.
> 
> Attached is a patch which fixes this.

Thanks.  Would it be possible/easy to add a test for this?




Reply sent to Eli Zaretskii <eliz <at> gnu.org>:
You have taken responsibility. (Sat, 20 Dec 2025 13:15:02 GMT) Full text and rfc822 format available.

Notification sent to Jostein Kjønigsen <jostein <at> secure.kjonigsen.net>:
bug acknowledged by developer. (Sat, 20 Dec 2025 13:15:02 GMT) Full text and rfc822 format available.

Message #13 received at 80038-done <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Jostein Kjønigsen <jostein <at> secure.kjonigsen.net>
Cc: casouri <at> gmail.com, theo <at> thornhill.no, 80038-done <at> debbugs.gnu.org
Subject: Re: bug#80038: [PATCH] 31.0.50;
 csharp-ts-mode: Fontification of caught exceptions is incorrect
Date: Sat, 20 Dec 2025 15:14:14 +0200
> Cc: Yuan Fu <casouri <at> gmail.com>, Theodor Thornhill <theo <at> thornhill.no>
> From: Jostein Kjønigsen <jostein <at> secure.kjonigsen.net>
> Date: Fri, 19 Dec 2025 21:50:12 +0100
> 
> When you create a basic try/catch expression in C# using csharp-ts-mode
> it gets fontified incorrectly.
> 
> Example:
> 
> try
> {
>    // buggy code
> }
> catch (Exception ex)
> {
>    // other code
> }
> 
> In this case "Exception" will be fontified using
> font-lock-type-face. This is correct.
> 
> However "ex" is also fontified as font-lock-type-face. This is
> incorrect. It should be fontifified as font-lock-variable-name-face.
> 
> Attached is a patch which fixes this.

Thanks, installed on master, and closing the bug.




This bug report was last modified 7 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.