Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conflict with electric-pair-mode #1188

Closed
raxod502 opened this issue Sep 6, 2017 · 4 comments
Closed

Conflict with electric-pair-mode #1188

raxod502 opened this issue Sep 6, 2017 · 4 comments

Comments

@raxod502
Copy link
Contributor

raxod502 commented Sep 6, 2017

Method to reproduce:

  • Load swiper, revision bf0e4388d7c30914a3cc62c0472b5b8207d9b2e6.
  • Run M-x electric-pair-mode.
  • Run M-x swiper.
  • Type [^ (left bracket, caret, space). Due to electric-pair-mode this results in [^ ], where point is before the right bracket.
  • Error in post-command-hook (ivy--exhibit): (wrong-type-argument number-or-marker-p nil)

Using M-x toggle-debug-on-error does not produce a stack trace.

System information

GNU Emacs 25.2.1 (x86_64-apple-darwin13.4.0, NS appkit-1265.21 Version 10.9.5 (Build 13F1911)) of 2017-04-21

installed from brew cask.

                -/+:.           raxod502
               :++++.           -------------------------------------
              /+++/.            OS: OS X El Capitan 10.11.6 15G1611 x86_64
      .:-::- .+/:-``.::-        Model: MacBookPro11,3
   .:/++++++/::::/++++++/:`     Kernel: 15.6.0
 .:///////////////////////:`    Uptime: 15 days, 22 hours, 55 minutes
 ////////////////////////`      Packages: 408
-+++++++++++++++++++++++`       Shell: zsh 5.4.1
/++++++++++++++++++++++/        Resolution: 3008x1692@2x, 1440x900@2x
/sssssssssssssssssssssss.       DE: Aqua
:ssssssssssssssssssssssss-      WM: Quartz Compositor
 osssssssssssssssssssssssso/`   WM Theme: Blue
 `syyyyyyyyyyyyyyyyyyyyyyyy+`   Terminal: iTerm2
  `ossssssssssssssssssssss/     Terminal Font: InputMono-Medium 14
    :ooooooooooooooooooo+.      CPU: Intel i7-4980HQ (8) @ 2.80GHz
     `:+oo+/:-..-:/+o+/-        GPU: Intel Iris Pro, NVIDIA GeForce GT 750M
                                Memory: 2651MiB / 16384MiB
@mookid
Copy link
Contributor

mookid commented Sep 8, 2017

It can be reproduced with just (swiper "[^ ]") non-interactively.

the following patch seems to avoid the crash:

diff --git a/swiper.el b/swiper.el
index e7dfee2..26efa35 100644
--- a/swiper.el
+++ b/swiper.el
@@ -659,15 +659,18 @@ WND, when specified is the window."
               (while (<= (cl-incf j) ivy--subexps)
                 (let ((bm (match-beginning j))
                       (em (match-end j)))
-                  (while (and (< j ivy--subexps)
-                              (= em (match-beginning (+ j 1))))
-                    (setq em (match-end (cl-incf j))))
-                  (swiper--add-overlay
-                   bm em
-                   (nth (1+ (mod (+ i 2) (1- (length swiper-faces))))
-                        swiper-faces)
-                   wnd i)
-                  (cl-incf i))))))))))
+                  (when (and (integerp em)
+                             (integerp bm))
+                    (while (and (< j ivy--subexps)
+                                (integerp (match-beginning (+ j 1)))
+                                (= em (match-beginning (+ j 1))))
+                      (setq em (match-end (cl-incf j))))
+                    (swiper--add-overlay
+                     bm em
+                     (nth (1+ (mod (+ i 2) (1- (length swiper-faces))))
+                          swiper-faces)
+                     wnd i)
+                    (cl-incf i)))))))))))

 (defun swiper--add-overlay (beg end face wnd priority)
   "Add overlay bound by BEG and END to `swiper--overlays'.

@abo-abo
Copy link
Owner

abo-abo commented Sep 8, 2017

@mookid Please PR.

mookid added a commit to mookid/swiper that referenced this issue Sep 8, 2017
This triggered an error on (swiper "[^ ]") (see abo-abo#1188).
@abo-abo
Copy link
Owner

abo-abo commented Sep 11, 2017

@raxod502 Please test.

@raxod502
Copy link
Contributor Author

@abo-abo Works for me now. Thanks! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants