Package: emacs;
Reported by: Ruijie Yu <ruijie <at> netyu.xyz>
Date: Tue, 21 Mar 2023 03:01:02 UTC
Severity: normal
Found in version 30.0.50
To reply to this bug, email your comments to 62315 AT debbugs.gnu.org.
Toggle the display of automated, internal messages from the tracker.
View this report as an mbox folder, status mbox, maintainer mbox
bug-gnu-emacs <at> gnu.org
:bug#62315
; Package emacs
.
(Tue, 21 Mar 2023 03:01:02 GMT) Full text and rfc822 format available.Ruijie Yu <ruijie <at> netyu.xyz>
:bug-gnu-emacs <at> gnu.org
.
(Tue, 21 Mar 2023 03:01:02 GMT) Full text and rfc822 format available.Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
From: Ruijie Yu <ruijie <at> netyu.xyz> To: bug-gnu-emacs <at> gnu.org Subject: 30.0.50; [BUG] Rust eglot tuple struct field completion Date: Tue, 21 Mar 2023 10:33:48 +0800
I can't word it, so let me explain via an example. The Emacs in question was built a few days ago, FTR. Also, note that I am using rust-ts-mode as the major mode, since it is the only builtin rust major mode, with the corresponding grammar lib cloned and built moments ago. $ cd "$(mktemp -d)" $ cargo init --name foo --lib $ emacs -Q src/lib.rs Replace src/lib.rs with the following content, then revert buffer and run `eglot': --8<---------------cut here---------------start------------->8--- // -*- mode: rust-ts; -*- /// 0..=10 #[derive(Default)] struct Foo(u32, u32, u32, u32, u32, u32, u32, u32, u32, u32, u32); fn foo(f: Foo) -> u32 { f. } --8<---------------cut here---------------end--------------->8--- Put point after "f.", and type any number between (inclusive) 0 and 10, and type TAB. Observe that the number is repeated. This even happens with 1, where I expect to have "10" as a completion candidate. I use a rather large tuple struct in this example because I want to demonstrate that this issue should be happening for all magnitude of tuple indices, not just a single digit. --8<---------------cut here---------------start------------->8--- In GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.37, cairo version 1.17.8) of 2023-03-11 built on fw.net.yu Repository revision: c6bfffa9fe1af7f4f806e5533ba5f3c33476cf9a Repository branch: master System Description: Arch Linux Configured using: 'configure --with-pgtk' Configured features: ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG JSON LCMS2 LIBOTF LIBSYSTEMD LIBXML2 MODULES NOTIFY INOTIFY PDUMPER PGTK PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS TREE_SITTER WEBP XIM GTK3 ZLIB Important settings: value of $LANG: en_US.UTF-8 value of $XMODIFIERS: @im=fcitx locale-coding-system: utf-8-unix Major mode: Rust Minor modes in effect: eglot-inlay-hints-mode: t eglot--managed-mode: t flymake-mode: t text-scale-mode: t tooltip-mode: t global-eldoc-mode: t eldoc-mode: t show-paren-mode: t electric-indent-mode: t mouse-wheel-mode: t tool-bar-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-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 message mailcap yank-media puny dired dired-loaddefs rfc822 mml mml-sec epa derived epg rfc6068 epg-config gnus-util mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils time-date cl-extra eglot external-completion array filenotify jsonrpc ert pp ewoc debug backtrace find-func xref flymake-proc flymake warnings icons compile text-property-search comint ansi-osc ansi-color ring url-util url-parse auth-source eieio eieio-core cl-macs password-cache json subr-x map url-vars project byte-opt gv bytecomp byte-compile imenu pcase rust-ts-mode rx c-ts-common treesit cl-seq thingatpt help-fns radix-tree help-mode files-x format-spec face-remap vc-git diff-mode easy-mmode vc-dispatcher cl-loaddefs cl-lib rmc iso-transl tooltip cconv eldoc paren electric uniquify ediff-hook vc-hooks lisp-float-type elisp-mode mwheel term/pgtk-win pgtk-win term/common-win pgtk-dnd 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 dbusbind inotify dynamic-setting system-font-setting font-render-setting cairo gtk pgtk lcms2 multi-tty make-network-process emacs) --8<---------------cut here---------------end--------------->8--- -- Best, RY
bug-gnu-emacs <at> gnu.org
:bug#62315
; Package emacs
.
(Wed, 22 Mar 2023 05:14:01 GMT) Full text and rfc822 format available.Message #8 received at 62315 <at> debbugs.gnu.org (full text, mbox):
From: Ruijie Yu <ruijie <at> netyu.xyz> To: 62315 <at> debbugs.gnu.org Cc: João Távora <joaotavora <at> gmail.com> Subject: Re: 30.0.50; [BUG] Rust eglot tuple struct field completion Date: Wed, 22 Mar 2023 13:11:14 +0800
CC'ing João because eglot. Thanks. > I can't word it, so let me explain via an example. The Emacs in > question was built a few days ago, FTR. > > Also, note that I am using rust-ts-mode as the major mode, since > it is the only builtin rust major mode, with the corresponding grammar > lib cloned and built moments ago. > > $ cd "$(mktemp -d)" > $ cargo init --name foo --lib > $ emacs -Q src/lib.rs > > Replace src/lib.rs with the following content, then revert buffer and > run `eglot': > > // -*- mode: rust-ts; -*- > /// 0..=10 > #[derive(Default)] > struct Foo(u32, u32, u32, u32, u32, u32, u32, u32, u32, u32, u32); > > fn foo(f: Foo) -> u32 { > f. > } > > > Put point after "f.", and type any number between (inclusive) 0 and 10, > and type TAB. Observe that the number is repeated. This even happens > with 1, where I expect to have "10" as a completion candidate. > > I use a rather large tuple struct in this example because I want to > demonstrate that this issue should be happening for all magnitude of > tuple indices, not just a single digit. > > In GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version > 3.24.37, cairo version 1.17.8) of 2023-03-11 built on fw.net.yu > Repository revision: c6bfffa9fe1af7f4f806e5533ba5f3c33476cf9a > Repository branch: master > System Description: Arch Linux > > Configured using: > 'configure --with-pgtk' > > Configured features: > ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG > JSON LCMS2 LIBOTF LIBSYSTEMD LIBXML2 MODULES NOTIFY INOTIFY PDUMPER PGTK > PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS > TREE_SITTER WEBP XIM GTK3 ZLIB > > Important settings: > value of $LANG: en_US.UTF-8 > value of $XMODIFIERS: @im=fcitx > locale-coding-system: utf-8-unix > > Major mode: Rust > > Minor modes in effect: > eglot-inlay-hints-mode: t > eglot--managed-mode: t > flymake-mode: t > text-scale-mode: t > tooltip-mode: t > global-eldoc-mode: t > eldoc-mode: t > show-paren-mode: t > electric-indent-mode: t > mouse-wheel-mode: t > tool-bar-mode: t > menu-bar-mode: t > file-name-shadow-mode: t > global-font-lock-mode: t > font-lock-mode: t > blink-cursor-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 message mailcap yank-media puny dired > dired-loaddefs rfc822 mml mml-sec epa derived epg rfc6068 epg-config > gnus-util mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev > gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util > mail-prsvr mail-utils time-date cl-extra eglot external-completion array > filenotify jsonrpc ert pp ewoc debug backtrace find-func xref > flymake-proc flymake warnings icons compile text-property-search comint > ansi-osc ansi-color ring url-util url-parse auth-source eieio eieio-core > cl-macs password-cache json subr-x map url-vars project byte-opt gv > bytecomp byte-compile imenu pcase rust-ts-mode rx c-ts-common treesit > cl-seq thingatpt help-fns radix-tree help-mode files-x format-spec > face-remap vc-git diff-mode easy-mmode vc-dispatcher cl-loaddefs cl-lib > rmc iso-transl tooltip cconv eldoc paren electric uniquify ediff-hook > vc-hooks lisp-float-type elisp-mode mwheel term/pgtk-win pgtk-win > term/common-win pgtk-dnd 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 dbusbind inotify dynamic-setting system-font-setting > font-render-setting cairo gtk pgtk lcms2 multi-tty make-network-process > emacs) -- Best, RY
bug-gnu-emacs <at> gnu.org
:bug#62315
; Package emacs
.
(Wed, 22 Mar 2023 10:36:01 GMT) Full text and rfc822 format available.Message #11 received at 62315 <at> debbugs.gnu.org (full text, mbox):
From: João Távora <joaotavora <at> gmail.com> To: Ruijie Yu <ruijie <at> netyu.xyz> Cc: 62315 <at> debbugs.gnu.org Subject: Re: 30.0.50; [BUG] Rust eglot tuple struct field completion Date: Wed, 22 Mar 2023 10:37:49 +0000
Ruijie Yu <ruijie <at> netyu.xyz> writes: > CC'ing João because eglot. Thanks. > >> I can't word it, so let me explain via an example. The Emacs in >> question was built a few days ago, FTR. >> >> Also, note that I am using rust-ts-mode as the major mode, since >> it is the only builtin rust major mode, with the corresponding grammar >> lib cloned and built moments ago. >> >> $ cd "$(mktemp -d)" >> $ cargo init --name foo --lib >> $ emacs -Q src/lib.rs >> >> Replace src/lib.rs with the following content, then revert buffer and >> run `eglot': >> >> // -*- mode: rust-ts; -*- >> /// 0..=10 >> #[derive(Default)] >> struct Foo(u32, u32, u32, u32, u32, u32, u32, u32, u32, u32, u32); >> >> fn foo(f: Foo) -> u32 { >> f. >> } >> >> >> Put point after "f.", and type any number between (inclusive) 0 and 10, >> and type TAB. Hi, I could reproduce this, if instead of TAB I type M-TAB (or the equivalent C-M-i, both run completion-at-point). Rust-rs-mode is not needed (rust-mode from ELPA is the same). I'm not sure yet this isn't a server bug. After typing the 1, but before C-M-i, the line reads: f.1 Point is now in LSP position (:line 6 :character 7). After C-M-i, the interaction with the server is: [client-request] (id:6) Wed Mar 22 10:17:53 2023: (:jsonrpc "2.0" :id 6 :method "textDocument/completion" :params (:textDocument (:uri "file:///tmp/tmp.wLa6UWw1Nf/src/lib.rs") :position (:line 6 :character 7) :context (:triggerKind 1))) [server-reply] (id:6) Wed Mar 22 10:17:53 2023: (:jsonrpc "2.0" :id 6 :result (:isIncomplete t :items [(:label "0" :kind 5 :detail "u32" :filterText "0" :textEdit (:range (:start (:line 6 :character 7) :end (:line 6 :character 7)) :newText "0")) (:label "1" :kind 5 :detail "u32" :filterText "1" :textEdit (:range (:start (:line 6 :character 7) :end (:line 6 :character 7)) :newText "1")) (some elements elided for readability) Which means the server is offering to _insert_ an _additional_ '0', '1' etc at position 7. Emacs/Eglot is not doing the right thing, but I don't think the server is doing the right thing either. Probably the server should be saying "I don't have completions for this position given my current view of the document". Maybe this could be reported to the rust-analyzer people for their input. However, given this "faulty" server exchange, I'm inclined to say completion-at-point should offer to insert '0','1', and other completions, and not immediately insert the "1". João
bug-gnu-emacs <at> gnu.org
:bug#62315
; Package emacs
.
(Wed, 22 Mar 2023 14:57:02 GMT) Full text and rfc822 format available.Message #14 received at 62315 <at> debbugs.gnu.org (full text, mbox):
From: Ruijie Yu <ruijie <at> netyu.xyz> To: João Távora <joaotavora <at> gmail.com> Cc: 62315 <at> debbugs.gnu.org Subject: Re: 30.0.50; [BUG] Rust eglot tuple struct field completion Date: Wed, 22 Mar 2023 22:52:12 +0800
João Távora <joaotavora <at> gmail.com> writes: > [...] > Emacs/Eglot is not doing the right thing, but I don't think the server > is doing the right thing either. > > Probably the server should be saying "I don't have completions for this > position given my current view of the document". Maybe this could be > reported to the rust-analyzer people for their input. Thanks. I have filed an issue upstream in rust-analyzer: https://github.com/rust-lang/rust-analyzer/issues/14391. > However, given this "faulty" server exchange, I'm inclined to say > completion-at-point should offer to insert '0','1', and other > completions, and not immediately insert the "1". I agree, this change makes sense to me. > João -- Best, RY
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.