From 21659e7239d99f6d6f4fd454fd1a773964c62708 Mon Sep 17 00:00:00 2001 From: Erlend Tobiassen Date: Fri, 15 Jun 2018 12:50:36 +0200 Subject: [PATCH 1/4] Add unit test for long user configured chords. --- test/configuration/configuration.test.ts | 51 +++++++++++++++--------- 1 file changed, 33 insertions(+), 18 deletions(-) diff --git a/test/configuration/configuration.test.ts b/test/configuration/configuration.test.ts index 4dea4ac2703..5da7c141b3f 100644 --- a/test/configuration/configuration.test.ts +++ b/test/configuration/configuration.test.ts @@ -1,31 +1,46 @@ import * as assert from 'assert'; import * as srcConfiguration from '../../src/configuration/configuration'; -import { Globals } from '../../src/globals'; import * as testConfiguration from '../testConfiguration'; -import { reloadConfiguration } from '../testUtils'; +import { cleanUpWorkspace, setupWorkspace } from './../testUtils'; +import { getTestingFunctions } from '../testSimplifier'; +import { ModeName } from '../../src/mode/mode'; suite('Configuration', () => { - suiteSetup(() => { - let configuration = new testConfiguration.Configuration(); - configuration.leader = ''; - configuration.otherModesKeyBindingsNonRecursive = [ - { - before: ['leader', 'o'], - after: ['o', 'eSc', 'k'], - }, - ]; + const { newTest } = getTestingFunctions(); + const configuration = new testConfiguration.Configuration(); + configuration.leader = ''; + configuration.otherModesKeyBindingsNonRecursive = [ + { + before: ['leader', 'o'], + after: ['o', 'eSc', 'k'], + }, + { + before: ['', 'f', 'e', 's'], + after: ['v'], + }, + ]; - Globals.mockConfiguration = configuration; - reloadConfiguration(); + setup(async () => { + await setupWorkspace(configuration); }); + teardown(cleanUpWorkspace); + test('remappings are normalized', async () => { - let configuration = srcConfiguration.configuration; - let keybindings = configuration.otherModesKeyBindingsNonRecursive; + const normalizedKeybinds = srcConfiguration.configuration.otherModesKeyBindingsNonRecursive; + const testingKeybinds = configuration.otherModesKeyBindingsNonRecursive; + + assert.equal(normalizedKeybinds.length, testingKeybinds.length); + assert.deepEqual(normalizedKeybinds[0].before, [' ', 'o']); + assert.deepEqual(normalizedKeybinds[0].after, ['o', '', 'k']); + }); - assert.equal(keybindings.length, 1); - assert.deepEqual(keybindings[0].before, [' ', 'o']); - assert.deepEqual(keybindings[0].after, ['o', '', 'k']); + newTest({ + title: 'Can handle long key chords', + start: ['|'], + keysPressed: ' fes', + end: ['|'], + endMode: ModeName.Visual, }); }); From f88f988f2e9b4bb6e697b6fd0395d0b5198ee7de Mon Sep 17 00:00:00 2001 From: Erlend Tobiassen Date: Fri, 15 Jun 2018 13:16:37 +0200 Subject: [PATCH 2/4] Fixes #2735, don't reset 'recordedState.actionKeys' if there is a potential remap. --- src/mode/modeHandler.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mode/modeHandler.ts b/src/mode/modeHandler.ts index 64415f7156d..05254f419a7 100644 --- a/src/mode/modeHandler.ts +++ b/src/mode/modeHandler.ts @@ -350,9 +350,9 @@ export class ModeHandler implements vscode.Disposable { case KeypressState.NoPossibleMatch: if (!this._remappers.isPotentialRemap) { vimState.recordedState = new RecordedState(); - return vimState; } - break; + + return vimState; case KeypressState.WaitingOnKeys: return vimState; } From ca2973068859598d5eaa2b8b0c319ac185a31bce Mon Sep 17 00:00:00 2001 From: Jason Poon Date: Mon, 23 Jul 2018 12:14:29 -0700 Subject: [PATCH 3/4] Fix bad merge --- test/configuration/configuration.test.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/configuration/configuration.test.ts b/test/configuration/configuration.test.ts index 28216a1d183..933965266b2 100644 --- a/test/configuration/configuration.test.ts +++ b/test/configuration/configuration.test.ts @@ -15,6 +15,10 @@ suite('Configuration', () => { before: ['leader', 'o'], after: ['o', 'eSc', 'k'], }, + { + before: ['', 'f', 'e', 's'], + after: ['v'], + }, ]; configuration.whichwrap = 'h,l'; From 6516fff4aa37f6985dc39947e45401b111fbe52f Mon Sep 17 00:00:00 2001 From: Jason Poon Date: Mon, 23 Jul 2018 13:29:29 -0700 Subject: [PATCH 4/4] fix: fix bad merge --- test/configuration/configuration.test.ts | 41 ++++++++++++------------ 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/test/configuration/configuration.test.ts b/test/configuration/configuration.test.ts index 933965266b2..f64d799f3d2 100644 --- a/test/configuration/configuration.test.ts +++ b/test/configuration/configuration.test.ts @@ -7,24 +7,23 @@ import { getTestingFunctions } from '../testSimplifier'; import { ModeName } from '../../src/mode/mode'; suite('Configuration', () => { - suiteSetup(() => { - let configuration = new testConfiguration.Configuration(); - configuration.leader = ''; - configuration.normalModeKeyBindingsNonRecursive = [ - { - before: ['leader', 'o'], - after: ['o', 'eSc', 'k'], - }, - { - before: ['', 'f', 'e', 's'], - after: ['v'], - }, - ]; - - configuration.whichwrap = 'h,l'; - - Globals.mockConfiguration = configuration; - reloadConfiguration(); + const { newTest } = getTestingFunctions(); + let configuration = new testConfiguration.Configuration(); + configuration.leader = ''; + configuration.normalModeKeyBindingsNonRecursive = [ + { + before: ['leader', 'o'], + after: ['o', 'eSc', 'k'], + }, + { + before: ['', 'f', 'e', 's'], + after: ['v'], + }, + ]; + configuration.whichwrap = 'h,l'; + + setup(async () => { + await setupWorkspace(configuration); }); teardown(cleanUpWorkspace); @@ -47,12 +46,12 @@ suite('Configuration', () => { }); test('whichwrap is parsed into wrapKeys', async () => { - let configuration = srcConfiguration.configuration; + let wrapKeys = srcConfiguration.configuration.wrapKeys; const h = 'h'; const j = 'j'; - assert.equal(configuration.wrapKeys[h], true); - assert.equal(configuration.wrapKeys[j], undefined); + assert.equal(wrapKeys[h], true); + assert.equal(wrapKeys[j], undefined); }); });