Skip to content

Commit

Permalink
Fix Shift-O on the last line of the file
Browse files Browse the repository at this point in the history
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 XVimProject#675
  • Loading branch information
keith authored and pebble8888 committed Jan 2, 2015
1 parent f5a959c commit 5dc1ba2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion XVim/NSTextStorage+VimOperation.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion XVim/NSTextView+VimOperation.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}

Expand Down

0 comments on commit 5dc1ba2

Please sign in to comment.