Skip to content

Commit

Permalink
Merge branch 'master' of github.com:VSCodeVim/Vim
Browse files Browse the repository at this point in the history
  • Loading branch information
johnfn committed Mar 18, 2017
2 parents 700ec40 + 7bb0a83 commit b071de6
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions src/actions/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5560,23 +5560,28 @@ class MoveToMatchingBracket extends BaseMovement {
}
}

// % has a special mode that lets you use it to jump to a percentage of the file
public async execActionWithCount(position: Position, vimState: VimState, count: number): Promise<Position | IMovement> {
if (count === 0) {
if (vimState.recordedState.operator) {
return this.execActionForOperator(position, vimState);
} else {
return this.execAction(position, vimState);
// % has a special mode that lets you use it to jump to a percentage of the file
// However, some other bracket motions inherit from this so only do this behavior for % explicitly
if (Object.getPrototypeOf(this) === MoveToMatchingBracket.prototype) {
if (count === 0) {
if (vimState.recordedState.operator) {
return this.execActionForOperator(position, vimState);
} else {
return this.execAction(position, vimState);
}
}
}

// Check to make sure this is a valid percentage
if (count < 0 || count > 100) {
return { start: position, stop: position, failed: true };
}
// Check to make sure this is a valid percentage
if (count < 0 || count > 100) {
return { start: position, stop: position, failed: true };
}

const targetLine = Math.round((count * TextEditor.getLineCount()) / 100);
return new Position(targetLine - 1, 0).getFirstLineNonBlankChar();
const targetLine = Math.round((count * TextEditor.getLineCount()) / 100);
return new Position(targetLine - 1, 0).getFirstLineNonBlankChar();
} else {
return super.execActionWithCount(position, vimState, count);
}
}
}

Expand Down

0 comments on commit b071de6

Please sign in to comment.