From 0e3df8fd7b4946cb9d3c8d9943a85af3e88bde82 Mon Sep 17 00:00:00 2001 From: "Yuichiro Tachibana (Tsuchiya)" Date: Sat, 26 Jul 2025 21:58:16 +0200 Subject: [PATCH 1/3] Fix the extension test checking the configuration fields. * The predicate function passed to `key.filter()` was wrong. To extract the unhandled keys, the predicate should be `!handlers.includes(key)`, but it was inverted. * `key` obtained from `package.json` is prefixed with `vim.` while `handler` doesn't have the prefix. It was not taken care of when checking `handlers.includes(key)`. * As a combination of these two mistakes, the test case has been passed, however, practically it has been checking nothing. --- test/extension.test.ts | 48 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 42 insertions(+), 6 deletions(-) diff --git a/test/extension.test.ts b/test/extension.test.ts index 934e2af218c..595264fba5d 100644 --- a/test/extension.test.ts +++ b/test/extension.test.ts @@ -27,15 +27,51 @@ suite('package.json', () => { assert.ok(pkgConfigurations); const keys = Object.keys(pkgConfigurations); assert.notStrictEqual(keys.length, 0); + assert.ok(keys.every((key) => key.startsWith('vim.'))); // configuration - let handlers = Object.keys(srcConfiguration.configuration); - let unhandled = keys.filter((k) => handlers.includes(k)); - assert.strictEqual(unhandled.length, 0, 'Missing src handlers for ' + unhandled.join(',')); + const srcHandlers = Object.keys(srcConfiguration.configuration); + const srcUnhandled = keys.filter((key) => { + const keyFirstSegment = key.split('.')[1]; // Extract the first segment without the `vim.` prefix from `key`, e.g. get `foo` from 'vim.foo.bar.baz'. + const propertyExists = srcHandlers.includes(keyFirstSegment); + if (propertyExists) { + return false; + } + + // If the property doesn't exist, check the possibility that the field is implemented as a get proxy by calling it. + if (srcConfiguration.configuration[keyFirstSegment]) { + return false; + } + + return true; + }); + assert.strictEqual( + srcUnhandled.length, + 0, + 'Missing src handlers for ' + srcUnhandled.join(','), + ); // test configuration - handlers = Object.keys(new testConfiguration.Configuration()); - unhandled = keys.filter((k) => handlers.includes(k)); - assert.strictEqual(unhandled.length, 0, 'Missing test handlers for ' + unhandled.join(',')); + const testConfigurationInstance = new testConfiguration.Configuration(); + const testHandlers = Object.keys(testConfigurationInstance); + const testUnhandled = keys.filter((key) => { + const keyFirstSegment = key.split('.')[1]; // Extract the first segment without the `vim.` prefix from `key`, e.g. get `foo` from 'vim.foo.bar.baz'. + const propertyExists = testHandlers.includes(keyFirstSegment); + if (propertyExists) { + return false; + } + + // If the property doesn't exist, check the possibility that the field is implemented as a get proxy by calling it. + if (testConfigurationInstance[keyFirstSegment]) { + return false; + } + + return true; + }); + assert.strictEqual( + testUnhandled.length, + 0, + 'Missing test handlers for ' + testUnhandled.join(','), + ); }); }); From 50dd239d06d8765aa830e44b969528bf0ddfb55b Mon Sep 17 00:00:00 2001 From: "Yuichiro Tachibana (Tsuchiya)" Date: Sat, 26 Jul 2025 22:04:56 +0200 Subject: [PATCH 2/3] Refactoring --- test/extension.test.ts | 32 +++++++++++--------------------- 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/test/extension.test.ts b/test/extension.test.ts index 595264fba5d..d777f8c4a99 100644 --- a/test/extension.test.ts +++ b/test/extension.test.ts @@ -5,6 +5,7 @@ import * as srcConfiguration from '../src/configuration/configuration'; import * as testConfiguration from './testConfiguration'; import * as packagejson from '../package.json'; +import { IConfiguration } from 'src/configuration/iconfiguration'; suite('package.json', () => { test('all keys have handlers', async () => { @@ -29,22 +30,25 @@ suite('package.json', () => { assert.notStrictEqual(keys.length, 0); assert.ok(keys.every((key) => key.startsWith('vim.'))); - // configuration - const srcHandlers = Object.keys(srcConfiguration.configuration); - const srcUnhandled = keys.filter((key) => { + const isUnhandled = (configuration: IConfiguration, key: string): boolean => { const keyFirstSegment = key.split('.')[1]; // Extract the first segment without the `vim.` prefix from `key`, e.g. get `foo` from 'vim.foo.bar.baz'. - const propertyExists = srcHandlers.includes(keyFirstSegment); + + const handlers = Object.keys(configuration); + const propertyExists = handlers.includes(keyFirstSegment); if (propertyExists) { return false; } // If the property doesn't exist, check the possibility that the field is implemented as a get proxy by calling it. - if (srcConfiguration.configuration[keyFirstSegment]) { + if (configuration[keyFirstSegment]) { return false; } return true; - }); + }; + + // configuration + const srcUnhandled = keys.filter(isUnhandled.bind(null, srcConfiguration.configuration)); assert.strictEqual( srcUnhandled.length, 0, @@ -53,21 +57,7 @@ suite('package.json', () => { // test configuration const testConfigurationInstance = new testConfiguration.Configuration(); - const testHandlers = Object.keys(testConfigurationInstance); - const testUnhandled = keys.filter((key) => { - const keyFirstSegment = key.split('.')[1]; // Extract the first segment without the `vim.` prefix from `key`, e.g. get `foo` from 'vim.foo.bar.baz'. - const propertyExists = testHandlers.includes(keyFirstSegment); - if (propertyExists) { - return false; - } - - // If the property doesn't exist, check the possibility that the field is implemented as a get proxy by calling it. - if (testConfigurationInstance[keyFirstSegment]) { - return false; - } - - return true; - }); + const testUnhandled = keys.filter(isUnhandled.bind(null, testConfigurationInstance)); assert.strictEqual( testUnhandled.length, 0, From be84e5a73c34ed263687749fda972c340e96da87 Mon Sep 17 00:00:00 2001 From: "Yuichiro Tachibana (Tsuchiya)" Date: Sat, 26 Jul 2025 22:06:40 +0200 Subject: [PATCH 3/3] Fix testConfiguration adding a missing property that was detected by the fixed test --- test/testConfiguration.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/testConfiguration.ts b/test/testConfiguration.ts index 614976d110e..c3334e821b8 100644 --- a/test/testConfiguration.ts +++ b/test/testConfiguration.ts @@ -42,6 +42,8 @@ export class Configuration implements IConfiguration { easymotionDimBackground = true; easymotionMarkerFontWeight = 'bold'; easymotionKeys = 'hklyuiopnm,qwertzxcvbasdgjf;'; + easymotionJumpToAnywhereRegex = '\\b[A-Za-z0-9]|[A-Za-z0-9]\\b|_.|#.|[a-z][A-Z]'; + targets: ITargetsConfiguration = { enable: false, bracketObjects: {