Closed dackon closed 7 months ago
Thank you for reporting the issue.
Sadly, I cannot reproduce the crash on my side, but I haven't access to a Mac machine.
emacs crashed when input specific text
By specific text
, you mean 'use server;'
and press enter ? Does typing anything else like 'hello';
and pressing enter leads to the same crash ?
If Yes: it might be an issue with electric new line feature, try to disable it in your init.el
file ((setq jtsx-enable-electric-open-newline-between-jsx-element-tags nil)
).
If No: it might be related to lsp-mode
package. When you only comment out jtsx
part in your init.el
file, lsp-mode
is also disabled for JS/JSX/TS/TSX files unless you explicitly change lsp-mode
configuration at the same time. You can try to use tsx-ts-mode
instead of jtsx-tsx-mode
(see below) and check whether the crash is still there or not.
;;; package -- summary
;;; Commentary:
;;; Code:
;; load the package system and add some repositories
(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
(package-initialize)
;; https://emacs-lsp.github.io/lsp-mode/page/performance/
(setq gc-cons-threshold 100000000)
(setq read-process-output-max (* 1024 1024)) ;; 1mb
(use-package lsp-mode
:ensure t
:commands
(lsp lsp-deferred)
:hook
(lsp-mode . (lambda () (display-line-numbers-mode 1)))
:config
;; (add-hook 'jtsx-jsx-mode-hook 'lsp-deferred)
;; (add-hook 'jtsx-tsx-mode-hook 'lsp-deferred)
(add-hook 'tsx-ts-mode-hook 'lsp-deferred)
(setq js-indent-level 2)
(setq lsp-apply-edits-after-file-operations nil)
;; (with-eval-after-load 'js (define-key js-mode-map (kbd "M-.") nil))
(setq lsp-log-io nil)
(setq lsp-enable-snippet nil)
(setq lsp-print-performance nil)
(setq lsp-eslint-enable nil)
)
(add-to-list 'auto-mode-alist '("\\.tsx?\\'" . tsx-ts-mode))
;; (use-package jtsx
;; :ensure t
;; :mode (("\\.jsx?\\'" . jtsx-jsx-mode)
;; ("\\.tsx?\\'" . jtsx-tsx-mode))
;; :commands jtsx-install-treesit-language
;; :hook ((jtsx-jsx-mode . hs-minor-mode)
;; (jtsx-tsx-mode . hs-minor-mode))
;; :custom
;; (js-indent-level 2)
;; :config
;; (defun jtsx-bind-keys-to-mode-map (mode-map)
;; "Bind keys to MODE-MAP."
;; (define-key mode-map (kbd "C-c C-j") 'jtsx-jump-jsx-element-tag-dwim)
;; (define-key mode-map (kbd "C-c j o") 'jtsx-jump-jsx-opening-tag)
;; (define-key mode-map (kbd "C-c j c") 'jtsx-jump-jsx-closing-tag)
;; (define-key mode-map (kbd "C-c j r") 'jtsx-rename-jsx-element)
;; (define-key mode-map (kbd "C-c <down>") 'jtsx-move-jsx-element-tag-forward)
;; (define-key mode-map (kbd "C-c <up>") 'jtsx-move-jsx-element-tag-backward)
;; (define-key mode-map (kbd "C-c C-<down>") 'jtsx-move-jsx-element-forward)
;; (define-key mode-map (kbd "C-c C-<up>") 'jtsx-move-jsx-element-backward)
;; (define-key mode-map (kbd "C-c C-S-<down>") 'jtsx-move-jsx-element-step-in-forward)
;; (define-key mode-map (kbd "C-c C-S-<up>") 'jtsx-move-jsx-element-step-in-backward)
;; (define-key mode-map (kbd "C-c j w") 'jtsx-wrap-in-jsx-element)
;; (define-key mode-map (kbd "C-c j u") 'jtsx-unwrap-jsx)
;; (define-key mode-map (kbd "M-.") 'nil)
;; (define-key mode-map (kbd "C-c j d") 'jtsx-delete-jsx-node))
;; (defun jtsx-bind-keys-to-jtsx-jsx-mode-map ()
;; (jtsx-bind-keys-to-mode-map jtsx-jsx-mode-map))
;; (defun jtsx-bind-keys-to-jtsx-tsx-mode-map ()
;; (jtsx-bind-keys-to-mode-map jtsx-tsx-mode-map))
;; (add-hook 'jtsx-jsx-mode-hook 'jtsx-bind-keys-to-jtsx-jsx-mode-map)
;; (add-hook 'jtsx-tsx-mode-hook 'jtsx-bind-keys-to-jtsx-tsx-mode-map)
;; (setq jtsx-enable-all-syntax-highlighting-features nil)
;; (setq jtsx-enable-jsx-element-tags-auto-sync t)
;; )
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(package-selected-packages '(jtsx lsp-mode)))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)
It seems that 'hello';
also leads to a crash.
You're correct; disabling this option fixed the bug.
(setq jtsx-enable-electric-open-newline-between-jsx-element-tags nil)
Thank you.
Ok, so there should have a bug regarding electric new line feature under some circumstances.
According the issue description, I think it is located near this line. But without being able to reproduce it, I have no idea of what goes wrong and why.
Do not hesitate to add new informations that could help to track this bug.
I reopen the issue because it is not fully resolved.
After I made the change, it still crashed when I typed any keyword, e.g., import or function. Then, I thought it might be an lsp-mode bug, so I reverted several changes they had made recently. It still crashed, but it was working normally yesterday. Then, it occurred to me that I had updated packages in MacPorts. Maybe recompiling Emacs will fix the issue. After recompiling Emacs, the crash is gone with jtsx-enable-electric-open-newline-between-jsx-element-tags enabled. Thank you.
OK, good news. Closing the issue then.
I installed emacs from MacPort with no UI: GNU Emacs 29.3 (build 2, aarch64-apple-darwin23.4.0) of 2024-03-26. The bug does not occur if I comment out jtsx in my .emacs file.
Here is my .emacs