From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Theodor Thornhill via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#61532: 30.0.50; [PATCH]: Make completions without sortText fall to back of the list Date: Sat, 18 Feb 2023 23:18:18 +0100 Message-ID: <875yby62j9.fsf@thornhill.no> References: <87ttzn6kxb.fsf@thornhill.no> Reply-To: Theodor Thornhill Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="30193"; mail-complaints-to="usenet@ciao.gmane.io" Cc: joaotavora@gmail.com To: 61532@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Feb 18 23:19:18 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 1pTVY5-0007cM-MG for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 18 Feb 2023 23:19:18 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pTVXs-0006Vb-Uj; Sat, 18 Feb 2023 17:19:04 -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 1pTVXr-0006VE-Cb for bug-gnu-emacs@gnu.org; Sat, 18 Feb 2023 17:19: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 1pTVXr-0007ya-0V for bug-gnu-emacs@gnu.org; Sat, 18 Feb 2023 17:19:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pTVXq-0004Jj-CL for bug-gnu-emacs@gnu.org; Sat, 18 Feb 2023 17:19:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Theodor Thornhill Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 18 Feb 2023 22:19:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 61532 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 61532-submit@debbugs.gnu.org id=B61532.167675870516521 (code B ref 61532); Sat, 18 Feb 2023 22:19:02 +0000 Original-Received: (at 61532) by debbugs.gnu.org; 18 Feb 2023 22:18:25 +0000 Original-Received: from localhost ([127.0.0.1]:45120 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pTVXE-0004IP-UR for submit@debbugs.gnu.org; Sat, 18 Feb 2023 17:18:25 -0500 Original-Received: from out2.migadu.com ([188.165.223.204]:35264) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pTVXC-0004IC-6A for 61532@debbugs.gnu.org; Sat, 18 Feb 2023 17:18:23 -0500 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no; s=key1; t=1676758700; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Do+UDE6VEj/pH77M0B9oUTlK0F6ZDBW6hEU7ccv6I14=; b=SvpKZA49Qa48vGiQlt7O+gRQqj4/oCHFnYUQrt/pNbfp+Qyn8gBC7zZB98Q+l8/Topn098 3SAJUJ9IUKspHnDvYc0MhDue2oCoUus6BMdmThv1VeiaooszTPdUkEduP7cl85pKwlgvrT C9gKJvlzr2NR4S0192yeJXI6WlghUA/0rWcMOBvpjVqy9SUJLF2TV9LcUPrhzDjX1A4ilu EaPUo/iBaMo3MrNR5KFp6bv5P5e6KDya2+V3LEyVP1vdUdB2KAm2d8m1iGSRiQmbSzMW85 NAqLqByiE9p/55tXHYJEnKlyARlJbLPuqsT2henYG4F3h3maiaEk+C671fPuBA== In-Reply-To: <87ttzn6kxb.fsf@thornhill.no> (Theodor Thornhill's message of "Wed, 15 Feb 2023 15:52:00 +0100") X-Migadu-Flow: FLOW_OUT 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:256000 Archived-At: Ping :-) Theodor Thornhill writes: > Hi Joao and others! > > As I mentioned in a different Eglot bug I believed there was a problem > with sorting of candidates. It seems there kinda is, but it's a little > convoluted. To test this you need to have a server that supplies > snippets, or at least that sends some items with and without :sortText. > However, the code is simple enough, so it should be enough to read it. > > So, what happens with completion in Eglot that I find confusing is that > sometimes, candidates in the completion frameworks (company, corfu etc) > display candidates in a seemingly random order compared to what the > server sends. In particular, the Jdtls server sends snippets without > sorttext, which will be converted to the empty string in the sorter > function. That in turn will make all the snippets fall to the front of > the list as (string-lessp "" "anything else") evaluates to t. That > means we ignore the sorts supplied by the server. Because (string-lessp > nil "anything else") evaluates to nil it will put them at the end of the > list, which IMO makes more sense. > > In addition, the completion-category-defaults set by eglot uses flex, as > you know, so the display-sort-function will sort them very hungrily, > making them seem out of order. > > For example, if the candidates are (delete, deleteAll, deleteById) when > buffer content is (| is point): > > ``` > something.del| > ``` > > completion will display them in this order: (deleteAll, deleteById, > delete), which yet again "doesn't respect sort order". The latter issue > is fixed by setting > > (setq completion-category-overrides > '((eglot (styles basic partial-completion initials)))) > > or something else, which works, but is very convoluted and really not > documented anywhere, or did I miss it? > > The former issue is fixed in the supplied patch. Do you agree with what > I propose? We could also default to something like :label or > :insertText, but that would in some cases also likely conflict with what > the server is expected to send. > > Theo