From 4417b5ee769ce7e8b96071c9d2f1fb44b806bb0a Mon Sep 17 00:00:00 2001 From: Keith Smiley Date: Fri, 2 Jan 2015 07:32:47 -0800 Subject: [PATCH] Fix Shift-O on the last line of the file This fixes an issue where, when the start of the line is the last character of the file, there an off by 1 error that would cause shift-o not to work. `characterAtIndex` expects and index within the bounds of this string, the passed character index was previously the length of the string. This fixes #675 --- XVim/NSTextStorage+VimOperation.m | 2 +- XVim/NSTextView+VimOperation.m | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/XVim/NSTextStorage+VimOperation.m b/XVim/NSTextStorage+VimOperation.m index 0674b513..a2d81117 100644 --- a/XVim/NSTextStorage+VimOperation.m +++ b/XVim/NSTextStorage+VimOperation.m @@ -249,7 +249,7 @@ - (NSUInteger)xvim_firstOfLine:(NSUInteger)index { NSUInteger pos = [self xvim_startOfLine:index]; - if (pos == index && isNewline([self.xvim_string characterAtIndex:pos])) { + if (pos == index && isNewline([self.xvim_string characterAtIndex:(pos - 1)])) { return NSNotFound; } return pos; diff --git a/XVim/NSTextView+VimOperation.m b/XVim/NSTextView+VimOperation.m index 3b39742f..3bb7a2c0 100644 --- a/XVim/NSTextView+VimOperation.m +++ b/XVim/NSTextView+VimOperation.m @@ -380,7 +380,7 @@ - (void)_xvim_killSelection:(XVimSelection)sel **/ - (NSUInteger)insertionPoint{ - id ret = [self dataForName:@"insertionPoint"]; + NSNumber* ret = [self dataForName:@"insertionPoint"]; return nil == ret ? 0 : [ret unsignedIntegerValue]; }