From 6adcd24e68925bde3cf8af437390391578e7eae4 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 0a36ace1..1dd3d2e0 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 3f700896..bf604e82 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]; }