Bug 328044 - wrong behavior of vi command "s"
Summary: wrong behavior of vi command "s"
Status: RESOLVED FIXED
Alias: None
Product: kate
Classification: Applications
Component: Vi Input Mode (show other bugs)
Version: 3.11.2
Platform: unspecified Linux
: NOR major
Target Milestone: ---
Assignee: Michal Humpula
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-11-25 03:50 UTC by Franklin Weng
Modified: 2013-11-29 15:49 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
step 1: Original file (193.07 KB, image/jpeg)
2013-11-28 23:51 UTC, Franklin Weng
Details
step 2: use "8s" to replace the string (193.51 KB, image/jpeg)
2013-11-28 23:53 UTC, Franklin Weng
Details
step 3: type the replacing string (193.94 KB, image/jpeg)
2013-11-28 23:54 UTC, Franklin Weng
Details
step 4: press ESC, and "sdsd" was repeated 8 times. (194.26 KB, image/jpeg)
2013-11-28 23:55 UTC, Franklin Weng
Details
Quick fix for the issue (400 bytes, patch)
2013-11-29 14:44 UTC, Michal Humpula
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Franklin Weng 2013-11-25 03:50:04 UTC
In vim, I usually use command 's' to substitute a word.  For example,

"Kate is very good to use."

I want to change "very" to "quite", so I'll put the cursor to 'v' and press 's' '4' then input 'quite', and press ESC to exit the edit mode.

In Kate's vi mode, if I use it this way, it will become
"Kate is quitequitequitequite good to use."
after I press ESC.

The repeat times is exactly the number what I input after 's'.


Reproducible: Always

Steps to Reproduce:
1. Select vi mode in Kate
2. Use vi command 's' '5' to remove a 5-chars words
3. input another word and press ESC

Actual Results:  
The input words will show repeatedly.

Expected Results:  
The input words should show only once.
Comment 1 Michal Humpula 2013-11-28 21:19:46 UTC
Do you mean "4s" instead of "s4"? The later doesn't seems to work in my vim. What version of vim do you use? The "4s" variant seems to be working in kde 3.11.3 (guessing it will be the same in 3.11.2).
Comment 2 Franklin Weng 2013-11-28 23:51:05 UTC
Created attachment 83818 [details]
step 1: Original file

1 of 4 screenshots for this bug.  Step 1: Put the cursor to the string which will be replaced.
Comment 3 Franklin Weng 2013-11-28 23:52:10 UTC
(In reply to comment #1)
> Do you mean "4s" instead of "s4"? The later doesn't seems to work in my vim.
> What version of vim do you use? The "4s" variant seems to be working in kde
> 3.11.3 (guessing it will be the same in 3.11.2).

Yes, "4s" instead of "s4".  Sorry for my fault.

My vim version is 7.3.429.  It worked with "4s" command.
My kate version is also 3.11.3.  The behavior of "4s" is wrong.

I'll attach four screenshots to describe this bug.
Comment 4 Franklin Weng 2013-11-28 23:53:26 UTC
Created attachment 83819 [details]
step 2: use "8s" to replace the string

2 of 4 screenshots:  press '8' 's' to replace the string "Franklin".  "Franklin" was gone.
Comment 5 Franklin Weng 2013-11-28 23:54:20 UTC
Created attachment 83820 [details]
step 3: type the replacing string

3 of 4 screenshots: type the replacing string.  For example, "sdsd"
Comment 6 Franklin Weng 2013-11-28 23:55:31 UTC
Created attachment 83821 [details]
step 4: press ESC, and "sdsd" was repeated 8 times.

4 of 4 snapshots:  press ESC and the string "sdsd" was repeated 8 times.
Comment 7 Michal Humpula 2013-11-29 14:25:45 UTC
Thanks for report! I can replicate this even on devel version, but I think the fix won't be much complicated. Hang in there.
Comment 8 Michal Humpula 2013-11-29 14:44:57 UTC
Created attachment 83827 [details]
Quick fix for the issue

This patch should fix the issue. Applicable against 3.11.3 too.
Comment 9 Michal Humpula 2013-11-29 15:49:24 UTC
Git commit 1e8f5ecdcd04a7d5f69819c644c1c87ded5442fd by Michal Humpula.
Committed on 29/11/2013 at 14:50.
Pushed by michalhumpula into branch 'master'.

vi-mode: fix normal mode "s" command repeat

make "4sfoo\\esc" work as expected
REVIEW: 114205

M  +2    -0    part/vimode/katevinormalmode.cpp
M  +3    -0    tests/vimode_test.cpp

http://commits.kde.org/kate/1e8f5ecdcd04a7d5f69819c644c1c87ded5442fd