`:'<,'>s` produces incorrect result if replacement has more lines than search pattern.
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 15.2k
- Forks
- 1.5k
- Avg merge
- 3d 18h
- Merged PRs (30d)
- 6
Description
Describe the bug
:'<,'>s produces an incomplete result if the replacement pattern results in more lines than search pattern.
To Reproduce
- Open a new file.
- Write five new lines, each containing the word
hello. - Enter visual line mode and select all five lines.
- Type
:s/hello/world\n\n/gand press enter (will expand to :'<,'>s/hello/world\n\n/gautomatically since multiple lines are selected.) - Only the first two lines are replaced, rather than all five of the lines. (I would assume the replacement is not updating some internal value used to keep track of which lines in the file are part of the requested range for the command.)
Expected behavior
Each of the five originally selected lines should be replaced with world\n\n, resulting in a 15-line file. The final file should look like this:
world
world
world
world
world
Environment (please complete the following information):
- Extension (VsCodeVim) version: 0.16.6
- VSCode version: 1.26.1
- OS: Linux x64 4.18.16-100.fc27.x86_64 (Fedora)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue in the VSCodeVim extension using visual line mode and the :'<,'>s/hello/world\n\n/g command. Trace how the selected range is handled when the replacement expands to multiple lines. Done means all five selected lines are replaced and the resulting file has 15 lines as shown in the report.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript, vscode
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 42/100