From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Lars Ingebrigtsen Newsgroups: gmane.emacs.bugs Subject: bug#42149: Substring and flex completion ignore implicit trailing =?UTF-8?Q?=E2=80=98any=E2=80=99?= Date: Thu, 13 May 2021 11:24:39 +0200 Message-ID: <877dk3rnoo.fsf@gnus.org> References: <87sgbsv7gg.fsf@gmail.com> <877dp1kfzz.fsf@gmail.com> <8735zpjz64.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="9308"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: 42149@debbugs.gnu.org, Dario Gjorgjevski , Stefan Monnier To: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu May 13 11:25:14 2021 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 1lh7aj-0002IY-W9 for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 13 May 2021 11:25:14 +0200 Original-Received: from localhost ([::1]:39298 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lh7ai-0008NL-Vv for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 13 May 2021 05:25:13 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:46092) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lh7aY-0008NA-Mi for bug-gnu-emacs@gnu.org; Thu, 13 May 2021 05:25:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:58014) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lh7aY-0004Av-GB for bug-gnu-emacs@gnu.org; Thu, 13 May 2021 05:25:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lh7aY-0006Vv-Bd for bug-gnu-emacs@gnu.org; Thu, 13 May 2021 05:25:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 13 May 2021 09:25:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 42149 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 42149-submit@debbugs.gnu.org id=B42149.162089789125019 (code B ref 42149); Thu, 13 May 2021 09:25:02 +0000 Original-Received: (at 42149) by debbugs.gnu.org; 13 May 2021 09:24:51 +0000 Original-Received: from localhost ([127.0.0.1]:41327 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lh7aN-0006VT-F5 for submit@debbugs.gnu.org; Thu, 13 May 2021 05:24:51 -0400 Original-Received: from quimby.gnus.org ([95.216.78.240]:40046) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lh7aL-0006VE-6b for 42149@debbugs.gnu.org; Thu, 13 May 2021 05:24:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID :In-Reply-To:Date:References:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=YI8h/2EawNH5XOdCQOD3fIupejgnErq4arxWYuc+rto=; b=JWxX0Wp/RY3HbTxlYLzBJgnGrG Grzopc444UDMd2/Q5vB/MR2mJjser07guVBgXf/xsMEHRKo2rmbkJ4ZoEfu7qNIAEz2NB7PqN5YjB m8TRkMuKnv9nv8HFnaVDAL9/RKJDNn9YNVozSk++1LMvf2mWpLKuemjwtnvdR3+Y5cf4=; Original-Received: from cm-84.212.220.105.getinternet.no ([84.212.220.105] helo=xo) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lh7aC-0002FA-I4; Thu, 13 May 2021 11:24:42 +0200 X-Now-Playing: Chrome Hoof's _Pre-Emptive False Rapture_: "Circus 9000" In-Reply-To: <8735zpjz64.fsf@gmail.com> ("=?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?="'s message of "Mon, 28 Dec 2020 23:20:19 +0000") 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" Xref: news.gmane.io gmane.emacs.bugs:206408 Archived-At: Jo=C3=A3o T=C3=A1vora writes: > And I just pushed my cleaned up fix to to master as well, thus hopefully > fixing the brunt of this bug. Dario and others, please test this. I > haven't yet pushed the tests, since we're not entirely sure of those, > but I think we should break them up further and push them too, once we > come to an aggreement on what and how they should test exactly. I've only skimmed this long thread, but my understanding of it is that the reported bug was fixed... but there was some discussion about including (or not) Dario's tests? Which (if I'm grepping correctly) would be the patch below? I tried applying it, and: 2 unexpected results: FAILED completion-pcm-all-completions-test FAILED completion-substring-all-completions-test I have not looked into this further -- Jo=C3=A3o, what's the state here? diff --git a/test/lisp/minibuffer-tests.el b/test/lisp/minibuffer-tests.el index 5da86f3614..a473fec441 100644 --- a/test/lisp/minibuffer-tests.el +++ b/test/lisp/minibuffer-tests.el @@ -104,5 +104,132 @@ nil (length input)) (cons output (length output))))))) =20 +(ert-deftest completion-pcm-all-completions-test () + ;; Point is at end, this does not match anything + (should (equal + (completion-pcm-all-completions + "foo" '("hello" "world" "barfoobar") nil 3) + nil)) + ;; Point is at beginning, this matches "barfoobar" + (should (equal + (car (completion-pcm-all-completions + "foo" '("hello" "world" "barfoobar") nil 0)) + "barfoobar")) + ;; Full match! + (should (eql + (get-text-property + 0 'completion-score + (car (completion-pcm-all-completions + "R" '("R" "hello") nil 1))) + 1.0)) + ;; One fourth of a match and no match due to point being at the end + (should (eql + (get-text-property + 0 'completion-score + (car (completion-pcm-all-completions + "RO" '("RaOb") nil 1))) + (/ 1.0 4.0))) + (should (equal + (completion-pcm-all-completions + "RO" '("RaOb") nil 2) + nil)) + ;; Point is at beginning, but `completions-first-difference' is + ;; moved after it + (should (equal + (get-text-property + 1 'face + (car (completion-pcm-all-completions + "f" '("few" "many") nil 0))) + 'completions-first-difference)) + ;; Wildcards and delimiters work + (should (equal + (car (completion-pcm-all-completions + "li-pac*" '("list-packages") nil 7)) + "list-packages")) + (should (equal + (car (completion-pcm-all-completions + "li-pac*" '("do-not-list-packages") nil 7)) + nil))) + +(ert-deftest completion-substring-all-completions-test () + ;; One third of a match! + (should (equal + (car (completion-substring-all-completions + "foo" '("hello" "world" "barfoobar") nil 3)) + "barfoobar")) + (should (eql + (get-text-property + 0 'completion-score + (car (completion-substring-all-completions + "foo" '("hello" "world" "barfoobar") nil 3))) + (/ 1.0 3.0))) + ;; Full match! + (should (eql + (get-text-property + 0 'completion-score + (car (completion-substring-all-completions + "R" '("R" "hello") nil 1))) + 1.0)) + ;; Substring match + (should (equal + (car (completion-substring-all-completions + "custgroup" '("customize-group") nil 4)) + "customize-group")) + (should (equal + (car (completion-substring-all-completions + "custgroup" '("customize-group") nil 5)) + nil)) + ;; `completions-first-difference' should be at the right place + (should (equal + (get-text-property + 4 'face + (car (completion-substring-all-completions + "jab" '("dabjobstabby" "many") nil 1))) + 'completions-first-difference)) + (should (equal + (get-text-property + 6 'face + (car (completion-substring-all-completions + "jab" '("dabjabstabby" "many") nil 1))) + 'completions-first-difference)) + (should (equal + (get-text-property + 6 'face + (car (completion-substring-all-completions + "jab" '("dabjabstabby" "many") nil 3))) + 'completions-first-difference))) + +(ert-deftest completion-flex-all-completions-test () + ;; Fuzzy match + (should (equal + (car (completion-flex-all-completions + "foo" '("hello" "world" "fabrobazo") nil 3)) + "fabrobazo")) + ;; Full match! + (should (eql + (get-text-property + 0 'completion-score + (car (completion-flex-all-completions + "R" '("R" "hello") nil 1))) + 1.0)) + ;; Another fuzzy match, but more of a "substring" one + (should (equal + (car (completion-flex-all-completions + "custgroup" '("customize-group-other-window") nil 4)) + "customize-group-other-window")) + ;; `completions-first-difference' should be at the right place + (should (equal + (get-text-property + 4 'face + (car (completion-flex-all-completions + "custgroup" '("customize-group-other-window") nil 4))) + 'completions-first-difference)) + (should (equal + (get-text-property + 15 'face + (car (completion-flex-all-completions + "custgroup" '("customize-group-other-window") nil 9))) + 'completions-first-difference))) + --=20 (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no