Skip to content

Commit

Permalink
Change variable name to better describe its use
Browse files Browse the repository at this point in the history
  • Loading branch information
berknam committed Apr 30, 2020
1 parent a469bd9 commit 11233dc
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions src/configuration/remapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export class Remapper implements IRemapper {
private readonly _logger = Logger.get('Remapper');

private _isPotentialRemap = false;
private _allowAmbiguousRemapOnFirstKey = true;
private _allowPotentialRemapOnFirstKey = true;
private _hasAmbiguousRemap = false;
get isPotentialRemap(): boolean {
return this._isPotentialRemap;
Expand Down Expand Up @@ -107,7 +107,6 @@ export class Remapper implements IRemapper {

let isPotentialRemap = false;
// Check to see if a remapping could potentially be applied when more keys are received
// const keysAsString = keys.join('');
const keysAsString = vimState.recordedState.commandWithoutCountPrefix.replace(
'<BufferedKeys>',
''
Expand All @@ -122,7 +121,7 @@ export class Remapper implements IRemapper {
}

this._isPotentialRemap =
isPotentialRemap && allowAmbiguousRemap && this._allowAmbiguousRemapOnFirstKey;
isPotentialRemap && allowAmbiguousRemap && this._allowPotentialRemapOnFirstKey;

if (
!remapping &&
Expand Down Expand Up @@ -150,16 +149,16 @@ export class Remapper implements IRemapper {
this._hasAmbiguousRemap = false;
if (!remapping) {
// if there is still no remapping, handle all the keys without allowing
// an ambiguous remap on the first key so that we don't repeat everything
// a potential remap on the first key so that we don't repeat everything
// again, but still allow for other ambiguous remaps after the first key.
//
// Example: if 'ii' and 'iiii' are mapped in normal and 'ii' is mapped in
// insert mode, and the user presses 'iiia' in normal mode or presses 'iii'
// and waits for the timeout to finish, we want the first 'i' to be handled
// without allowing ambiguous remaps, which means it will go into insert mode,
// Example: if 'iiii' is mapped in normal and 'ii' is mapped in insert mode,
// and the user presses 'iiia' in normal mode or presses 'iii' and waits
// for the timeout to finish, we want the first 'i' to be handled without
// allowing potential remaps, which means it will go into insert mode,
// but then the next 'ii' should be remapped in insert mode and after the
// remap the 'a' should be handled.
this._allowAmbiguousRemapOnFirstKey = false;
this._allowPotentialRemapOnFirstKey = false;
vimState.recordedState.commandList = vimState.recordedState.commandList.slice(
0,
-keys.length
Expand All @@ -169,7 +168,7 @@ export class Remapper implements IRemapper {
}
}

if (isPotentialRemap && allowAmbiguousRemap && this._allowAmbiguousRemapOnFirstKey) {
if (isPotentialRemap && allowAmbiguousRemap && this._allowPotentialRemapOnFirstKey) {
// There are other potential remaps (ambiguous remaps), wait for other
// key or for the timeout to finish.
this._hasAmbiguousRemap = true;
Expand All @@ -178,10 +177,10 @@ export class Remapper implements IRemapper {
modeHandler.handleKeyEvent('<BufferedKeys>');
}, configuration.timeout);
return true;
} else if (!this._allowAmbiguousRemapOnFirstKey) {
} else if (!this._allowPotentialRemapOnFirstKey) {
// First key was already prevented from buffering to wait for other remaps
// so we can allow for ambiguous remaps again.
this._allowAmbiguousRemapOnFirstKey = true;
this._allowPotentialRemapOnFirstKey = true;
}

if (remapping) {
Expand Down

0 comments on commit 11233dc

Please sign in to comment.