Skip to content

Commit

Permalink
Fix #1627. alphabet is not large enough :)
Browse files Browse the repository at this point in the history
  • Loading branch information
rebornix committed May 2, 2017
1 parent cad8b8e commit c227ea7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/actions/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}

Expand Down
8 changes: 6 additions & 2 deletions src/easymotion/easymotion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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()!);
}
}
Expand All @@ -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
Expand Down

0 comments on commit c227ea7

Please sign in to comment.