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

Confirm-Replace works incorrectly with global substitute for certain types of replace patterns #2950

Closed
khudyakoff opened this issue Aug 10, 2018 · 1 comment · Fixed by #3055
Labels

Comments

@khudyakoff
Copy link

khudyakoff commented Aug 10, 2018

Bug description
While using interactive confirm-replace with global substitute flag (either specified with /g option or vim.substituteGlobalFlag setting), the plugin adds multiple changes to the first occurrence of the matched pattern in the line and keeps further occurrences in the line unchanged or changes incorrectly. This only is reproduced by a certain rename types, esp. for 'pattern' -> 'pattern-new' or 'pattern' -> 'new-pattern'.

To Reproduce
Steps to reproduce the behavior:

  1. Open any file, find/create a line with the repeating pattern, like these:
    Occurrence #1: trololo, Occurrence #2: trololo, Occurrence #3: trololo

  2. Run the rename command (make sure you have vim.substituteGlobalFlag = true or use /g flag) and accept all subsitutions for the line (press y):
    Attempt 1: :s/trololo/trololo-new/cg
    Attempt 2: :s/trololo/new-trololo/cg

Expected behavior
Result for attempt 1: Occurrence #1: trololo-new, Occurrence #2: trololo-new, Occurrence #3: trololo-new
Result for attempt 2: Occurrence #1: new-trololo, Occurrence #2: new-trololo, Occurrence #3: new-trololo

What happened
Result for attempt 1: Occurrence #1: trololo-new-new-new, Occurrence #2: trololo, Occurrence #3: trololo trololololo
Result for attempt 2: Occurrence #1: new-new-new-trololo, Occurrence #2: trololo, Occurrence #3: trololo trololololo

Environment:

  • Extension (VsCodeVim) version:
    vim vsc 0.16.0
  • VSCode version:
    Version: 1.25.1
    Commit: 1dfc5e557209371715f655691b1235b6b26a06be
    Date: 2018-07-11T15:40:20.190Z
    Electron: 1.7.12
    Chrome: 58.0.3029.110
    Node.js: 7.9.0
    V8: 5.8.283.38
    Architecture: x64
  • OS:
    Ubuntu Linux 18.04
@MaerF0x0
Copy link

MaerF0x0 commented Sep 5, 2018

Similar test case happened to me:

Given source code

  SourceId: someId

I ran %s/Id/ID/gc then denied the first change (SourceId ==> SourceID) and confirmed the 2nd change (someId ==> someID) . However once the plugin applied my choices I received SourceID: someId , that is it applied to the first match on the line, not the one I confirmed on.

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

Successfully merging a pull request may close this issue.

3 participants