Skip to content

swiper: problems with input \_<foo\_> #298

Description

@zhaojiangbin

To reproduce it:

  1. Copy and paste the following into the scratch buffer, change the major mode to C++:
void g(int);
void g(int*);
void g(int,
       int*);
void g(int&,
       int);
void g(int,
       int*,
       int&);
void f(int one) {
    g(one);
    g(&one);
    g(one,
      &one);
    if (one>0
        &&(one+5)
        ==(one*2)) {
        g(one
          ,one);
    if (one<0)
        g(one,
          &one,
          one);
}
template <typename T> class C;
void g(C<int> arg);
  1. Move cursor to the first line, run swiper, then type \_<one\_> as the input.
  2. In the first screenshot below, see how there are 14 lines (from line 10 to line 23) highlighted in the scratch buffer while there are only 7 candidates listed in the minibuffer.
  3. Press C-n and C-p, swiper only visits the 7 lines in scratch buffer that are candidates. The other 7 highlighted lines are skipped over.
  4. Change the input to \_<int\_>.
  5. In the second screenshot below, see how there are 11 lines (line 1 to line 10, and line 26) highlighted in the scratch buffer while there are only 5 candidates listed in the minibuffer.
  6. Press M-q to start replacing the matches. Type in anything other than "int" as the replacement, followed by RET.
  7. Now watch swiper visiting all the 11 highlighted occurrences in buffer and replacing them as expected.

It appears that, for the pattern \_<K\_>, if an occurrence K in buffer adjoins some punctuation characters such as +, *, &, < and > (there might be more) on either or both sides, swiper can find and highlight the occurrence in buffer but somehow cannot add the match to candidate list. In comparison, isearch-forward-regexp is able to highlight and visit all of them as expected. And occurrences adjoining characters such as (, ), , (there might be more) are found and listed correctly.

There is more.

  1. Move the cursor to line 6 which swiper does find and add to candidate list.
  2. Run swiper and give input \_<int\_>.
  3. Watch the cursor jumping to the line 1 instead of staying at line 6.

It works as expected when the input pattern is \bK\b, \<K\>, or just K.

screen shot 2015-11-21 at 7 40 34 pm
screen shot 2015-11-21 at 8 21 05 pm

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions