From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: =?UTF-8?Q?K=C3=A9vin?= Le Gouguec Newsgroups: gmane.emacs.bugs Subject: bug#39680: Test case Date: Wed, 20 May 2020 00:05:18 +0200 Message-ID: <87tv0bfun5.fsf_-_@gmail.com> References: <87pneaifya.fsf@gmail.com> <20200225193451.GA5896@ACM> <87o8t4vhbh.fsf@gmail.com> <87d078ajzs.fsf@gmail.com> <87blmstg0v.fsf@gmail.com> <87blms6ww9.fsf@gmail.com> <877dxgtae9.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="35693"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: Alan Mackenzie , control@debbugs.gnu.org, Stefan Monnier , 39680@debbugs.gnu.org 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 Wed May 20 00:06:10 2020 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 1jbANF-0009Bg-Af for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 20 May 2020 00:06:09 +0200 Original-Received: from localhost ([::1]:39222 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jbANE-0003az-CE for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 19 May 2020 18:06:08 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:41932) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jbAN8-0003al-1n for bug-gnu-emacs@gnu.org; Tue, 19 May 2020 18:06:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:39773) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jbAN7-0005xr-PZ for bug-gnu-emacs@gnu.org; Tue, 19 May 2020 18:06:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jbAN7-0001GN-Kr for bug-gnu-emacs@gnu.org; Tue, 19 May 2020 18:06:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: =?UTF-8?Q?K=C3=A9vin?= Le Gouguec Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 19 May 2020 22:06:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 39680 X-GNU-PR-Package: emacs Original-Received: via spool by 39680-submit@debbugs.gnu.org id=B39680.15899259294813 (code B ref 39680); Tue, 19 May 2020 22:06:01 +0000 Original-Received: (at 39680) by debbugs.gnu.org; 19 May 2020 22:05:29 +0000 Original-Received: from localhost ([127.0.0.1]:51319 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jbAMa-0001FU-Jf for submit@debbugs.gnu.org; Tue, 19 May 2020 18:05:28 -0400 Original-Received: from mail-wr1-f44.google.com ([209.85.221.44]:45055) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jbAMY-0001FC-Nu; Tue, 19 May 2020 18:05:27 -0400 Original-Received: by mail-wr1-f44.google.com with SMTP id 50so1037738wrc.11; Tue, 19 May 2020 15:05:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=QNKNVAxA7Qw2YW0ZbrnV45YljtflGCrvEjgq0GhXIjI=; b=Z1RhnGpMTC347jR+87xyRG6kfKwOP62256Y0KQi7VH6KdWNVkJGfyN6WlSI99VJYnO b4ZOQwnirEHTgzigs4wS6keEZ/1eyTH2a4oBqT6zFMgOJ8WbBRiAP2xVeML8sxqbStnG LH3Ldh9UAmK7c3+jlWAvSFKl+5YU7gx2cSgX+a2/igGZUcAjfoSWnfbiq1E7eYiSo5i2 RZ1LMvr+NpmPTEEAtKfxfCtFhDLPlvlQrYu55Tfogsl/Gih+Bzx24SgFMAThJuAbetIE Cvnzu1QPIp46stm8Rw36Xm4c3lMcPaC4FRgrk6xwQhnZ7woNXPJ8VDdQt1mZz//oMRqW WrcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=QNKNVAxA7Qw2YW0ZbrnV45YljtflGCrvEjgq0GhXIjI=; b=EKG+LV7tr51zejN85EKIzcUY5ylwuzL8ZedA585OSjItWzmzjn5DNwDBVnrdSeDnZO wj9rMzci2G+LKVuKFGK0fXgaT8jBr4Q0e3Ue6ZkD0LPKdDwQDjkfGkdtuyTzDwWJw5g9 x4nqHxR1UI+Ennuk1MSKgbWlE4AHtXcgHGCr9AAZDpRPczG+Gt1vG25xQm5wjjqqu2Be Sr6RU/4vH7rPovUrh63iTuz3FbWapENdTZMdTdrgCFcN49RLoGf6iDk/s5tTpLoPxD3L U7wbQlehZc9/khZVKKfBC2PbsOBFKEtGPSHh77vRXnwGZX25XZu9rAgaWkNePi/0V/na ORJw== X-Gm-Message-State: AOAM533KSwASxRyFkCmUJ5KDZY7l/8YGG8ESDzrdrX8R7kd5svthpeKj at+yLRJsrsHHECMi6LgtFDt6bgnbAHnD/g== X-Google-Smtp-Source: ABdhPJwvIhJyh7U7CWtdllb5l1HczrsjCCSjTGwJXyj9Ph+8b4PWcKfmHDrpE1bVYkb9P056b3F8PQ== X-Received: by 2002:a5d:6108:: with SMTP id v8mr942956wrt.286.1589925920523; Tue, 19 May 2020 15:05:20 -0700 (PDT) Original-Received: from my-little-tumbleweed (200.143.13.109.rev.sfr.net. [109.13.143.200]) by smtp.gmail.com with ESMTPSA id j16sm789357wru.13.2020.05.19.15.05.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 May 2020 15:05:19 -0700 (PDT) In-Reply-To: <877dxgtae9.fsf@gmail.com> ("=?UTF-8?Q?K=C3=A9vin?= Le Gouguec"'s message of "Wed, 13 May 2020 12:08:30 +0200") 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:180617 Archived-At: --=-=-= Content-Type: text/plain Finally nailed it, after finding out about ert-simulate-command. The following patch adds a test that passes on master and emacs-27, and "successfully fails" when reverting Stefan's fix (commit c1ce9fa7f2). --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Add-test-for-bug-39680.patch >From c83fbd50f0f0999814f09706fc908df5c22c5a47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Le=20Gouguec?= Date: Tue, 19 May 2020 23:17:04 +0200 Subject: [PATCH] Add test for bug#39680 * test/lisp/electric-tests.el (electric-pair-undo-unrelated-state): New test. --- test/lisp/electric-tests.el | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/lisp/electric-tests.el b/test/lisp/electric-tests.el index 56d1bdb110..67f474cbd5 100644 --- a/test/lisp/electric-tests.el +++ b/test/lisp/electric-tests.el @@ -546,6 +546,24 @@ js-mode-braces-with-layout-and-indent (electric-pair-delete-pair 1) (should (equal "" (buffer-string)))))) + +;;; Undoing +(ert-deftest electric-pair-undo-unrelated-state () + "Make sure `electric-pair-mode' does not confuse `undo' (bug#39680)." + (with-temp-buffer + (buffer-enable-undo) + (electric-pair-local-mode) + (let ((last-command-event ?\()) + (ert-simulate-command '(self-insert-command 1))) + (undo-boundary) + (let ((last-command-event ?a)) + (ert-simulate-command '(self-insert-command 1))) + (undo-boundary) + (ert-simulate-command '(undo)) + (let ((last-command-event ?\()) + (ert-simulate-command '(self-insert-command 1))) + (should (string= (buffer-string) "(())")))) + ;;; Electric newlines between pairs ;;; TODO: better tests -- 2.26.2 --=-=-=--