XVimProject / XVim

Xcode plugin for Vim keybindings
MIT License
5.16k stars 596 forks source link

Crash when escape from Insert mode #38

Closed JugglerShu closed 12 years ago

JugglerShu commented 12 years ago

In XVimInsertEvaluator's "eval:ofXVim" when it handles it often crashes. The crash happend on 2nd line of below.

         NSString *text = [xvim string];
        NSString *insertedText = [text substringWithRange:textRange];
        [self recordText:insertedText intoRegister:[xvim findRegister:@"repeat"]];
        [self recordText:insertedText intoRegister:xvim.recordingRegister];

The debugger says the argument 'textRange' is {1710,18446744073709551613}. The big number means its length is "-3" I think this happens when you move cursor to some other place in insert mode especially when it moves back from the begining of insertion. I think if the cursor position had not move one way ( if some cursor movement is occured ), we can give up to save the inserted text.( This is vim's way)

dojoteef commented 12 years ago

Hmm.. So I just tried it out in vim. It appears that for the repeat '.' if you move the cursor during insert mode it ignores the previously typed text only if you actually type more text. For general macros it records all input. So I'll have to see what I can do to replicate that behavior.