diff --git a/src/actions/actions.ts b/src/actions/actions.ts index 2ec8ae52d79..29760558699 100644 --- a/src/actions/actions.ts +++ b/src/actions/actions.ts @@ -6650,7 +6650,10 @@ abstract class BaseEasyMotionCommand extends BaseCommand { continue; } - vimState.easyMotion.addMarker(EasyMotion.generateMarker(index++, matches.length, position, pos)); + let marker = EasyMotion.generateMarker(index++, matches.length, position, pos); + if (marker) { + vimState.easyMotion.addMarker(marker); + } } } diff --git a/src/easymotion/easymotion.ts b/src/easymotion/easymotion.ts index 515c46d512e..f8cddc76714 100644 --- a/src/easymotion/easymotion.ts +++ b/src/easymotion/easymotion.ts @@ -56,7 +56,7 @@ export class EasyMotion { /** * Generate a marker following a sequence for the name and depth levels */ - public static generateMarker(index: number, length: number, position: Position, markerPosition: Position): EasyMotion.Marker { + public static generateMarker(index: number, length: number, position: Position, markerPosition: Position): EasyMotion.Marker | null { let keyTable = EasyMotion.keyTable; var availableKeyTable = keyTable.slice(); @@ -68,7 +68,7 @@ export class EasyMotion { var totalRemainder = Math.max(length - keyTable.length, 0); totalSteps = Math.floor(totalRemainder / keyTable.length); - for (var i = 0; i < totalSteps; i++) { + for (var i = 0; i < Math.min(totalSteps, 26); i++) { keyDepthTable.push(availableKeyTable.pop()!); } } @@ -89,6 +89,10 @@ export class EasyMotion { var steps = Math.floor((inverted) / availableKeyTable.length); // Add the key to the prefix + if (steps > keyDepthTable.length - 1) { + return null; + } + prefix += keyDepthTable[steps]; // Check if we're on the last depth level