MCPcopy
hub / github.com/VSCodeVim/Vim / execActionWithCount

Method execActionWithCount

src/actions/motion.ts:1824–1852  ·  view source on GitHub ↗
(
    position: Position,
    vimState: VimState,
    count: number,
  )

Source from the content-addressed store, hash-verified

1822 }
1823
1824 public override async execActionWithCount(
1825 position: Position,
1826 vimState: VimState,
1827 count: number,
1828 ): Promise<Position | IMovement> {
1829 // % has a special mode that lets you use it to jump to a percentage of the file
1830 // However, some other bracket motions inherit from this so only do this behavior for % explicitly
1831 if (Object.getPrototypeOf(this) === MoveToMatchingBracket.prototype) {
1832 if (count === 0) {
1833 if (vimState.recordedState.operator) {
1834 return this.execActionForOperator(position, vimState);
1835 } else {
1836 return this.execAction(position, vimState);
1837 }
1838 }
1839
1840 // Check to make sure this is a valid percentage
1841 if (count < 0 || count > 100) {
1842 return failedMovement(vimState);
1843 }
1844
1845 // See `:help N%`
1846 const targetLine = Math.trunc((count * vimState.document.lineCount + 99) / 100) - 1;
1847
1848 return position.with({ line: targetLine }).obeyStartOfLine(vimState.document);
1849 } else {
1850 return super.execActionWithCount(position, vimState, count);
1851 }
1852 }
1853}
1854
1855export abstract class MoveInsideCharacter extends ExpandingSelection {

Callers

nothing calls this directly

Calls 5

execActionForOperatorMethod · 0.95
execActionMethod · 0.95
failedMovementFunction · 0.90
obeyStartOfLineMethod · 0.80
execActionWithCountMethod · 0.65

Tested by

no test coverage detected