Skip to content

Conversation

whitphx
Copy link
Contributor

@whitphx whitphx commented Jul 27, 2025

What this PR does / why we need it:
I found that this test case doesn't play its expected role.

let unhandled = keys.filter((k) => handlers.includes(k));

This line has the following bugs:

  1. The predicate method passed to keys.filter() has a wrong condition that should be inverted to extract unhandled keys as expected.
  2. keys contain the configuration keys prefixed with vim., while handlers contain non-prefixed ones. For example, keys[] is 'vim.useCtrlKeys' while handlers[] is 'useCtrlKeys'.
    So comparing them with handlers.includes(key) doesn't make any sense and it never be true.
  3. The dot-concatenated keys are converted to nested objects in the Configuration class (for example, the key 'vim.cursorStylePerMode.normal' will be mapped to {cursorStylePerMode: {normal: '<value>'}}), so the comparison of handlers.includes(key) doesn't work in such cases as well, because it compares the first-level object key like cursorStylePerMode with the dot-concatenated key like 'vim.cursorStylePerMode.normal'.

As a result of the combination of the wrong comparison (2) and the inverted boolean eval (1), the predicate returns the expected result (unhandled = []) by accident and the test has been passed. The problem (3) has also not been revealed due to it.

This PR fixes these bugs.
As a result, the fixed test detected a missing property in testConfiguration, so it's also fixed in be84e5a

Which issue(s) this PR fixes

Special notes for your reviewer:

whitphx added 3 commits July 26, 2025 21:58
* 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant