all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#62315: 30.0.50; [BUG] Rust eglot tuple struct field completion
@ 2023-03-21  2:33 Ruijie Yu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-03-22  5:11 ` Ruijie Yu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 4+ messages in thread
From: Ruijie Yu via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-03-21  2:33 UTC (permalink / raw)
  To: 62315

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





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#62315: 30.0.50; [BUG] Rust eglot tuple struct field completion
  2023-03-21  2:33 bug#62315: 30.0.50; [BUG] Rust eglot tuple struct field completion Ruijie Yu via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-03-22  5:11 ` Ruijie Yu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-03-22 10:37   ` João Távora
  0 siblings, 1 reply; 4+ messages in thread
From: Ruijie Yu via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-03-22  5:11 UTC (permalink / raw)
  To: 62315; +Cc: João Távora


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





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#62315: 30.0.50; [BUG] Rust eglot tuple struct field completion
  2023-03-22  5:11 ` Ruijie Yu via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-03-22 10:37   ` João Távora
  2023-03-22 14:52     ` Ruijie Yu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 4+ messages in thread
From: João Távora @ 2023-03-22 10:37 UTC (permalink / raw)
  To: Ruijie Yu; +Cc: 62315

Ruijie Yu <ruijie@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





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#62315: 30.0.50; [BUG] Rust eglot tuple struct field completion
  2023-03-22 10:37   ` João Távora
@ 2023-03-22 14:52     ` Ruijie Yu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 0 replies; 4+ messages in thread
From: Ruijie Yu via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-03-22 14:52 UTC (permalink / raw)
  To: João Távora; +Cc: 62315


João Távora <joaotavora@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





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-03-22 14:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-21  2:33 bug#62315: 30.0.50; [BUG] Rust eglot tuple struct field completion Ruijie Yu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-03-22  5:11 ` Ruijie Yu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-03-22 10:37   ` João Távora
2023-03-22 14:52     ` Ruijie Yu via Bug reports for GNU Emacs, the Swiss army knife of text editors

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.