From b5361251f096d5e930eac936f9f114e7e484ecee Mon Sep 17 00:00:00 2001 From: Takuya Matsuyama Date: Wed, 13 Mar 2024 11:00:06 +0900 Subject: [PATCH 1/5] fix(normalize): convert with-shift keys when normalizing https://forum.inkdrop.app/t/keybindings-with-numbers-and-the-shift-modifier-together-do-not-work/4482/2 --- spec/helpers-spec.js | 3 ++- src/helpers.js | 17 ++++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/spec/helpers-spec.js b/spec/helpers-spec.js index c6bae0b..3a31b48 100644 --- a/spec/helpers-spec.js +++ b/spec/helpers-spec.js @@ -16,7 +16,8 @@ describe('.normalizeKeystrokes(keystrokes)', () => assert.equal(normalizeKeystrokes('ctrl-x'), 'ctrl-x') assert.equal(normalizeKeystrokes('a'), 'a') assert.equal(normalizeKeystrokes('shift-a'), 'shift-A') - assert.equal(normalizeKeystrokes('shift-9'), 'shift-9') + assert.equal(normalizeKeystrokes('shift-9'), '(') + assert.equal(normalizeKeystrokes('shift'), 'shift') assert.equal(normalizeKeystrokes('-'), '-') assert.equal(normalizeKeystrokes('- -'), '- -') assert.equal(normalizeKeystrokes('a b'), 'a b') diff --git a/src/helpers.js b/src/helpers.js index d8271ec..5d8d053 100644 --- a/src/helpers.js +++ b/src/helpers.js @@ -142,9 +142,20 @@ var normalizeKeystroke = function (keystroke) { } else { if (isUpperCaseCharacter(primaryKey)) { modifiers.add('shift') - } - if (modifiers.has('shift') && isLowerCaseCharacter(primaryKey)) { - primaryKey = primaryKey.toUpperCase() + } else if (modifiers.has('shift')) { + if (isLowerCaseCharacter(primaryKey)) { + primaryKey = primaryKey.toUpperCase() + } else if (isLatinCharacter(primaryKey)) { + const characters = KeyboardLayout.getCurrentKeymap() + const code = Object.keys(characters).find( + code => characters[code].unmodified === primaryKey + ) + const keyWithShift = characters[code]?.withShift + if (keyWithShift) { + primaryKey = keyWithShift + modifiers.delete('shift') + } + } } } From 1f7c2e437b164895564f8404a80b7c20c7b2ff44 Mon Sep 17 00:00:00 2001 From: Takuya Matsuyama Date: Wed, 13 Mar 2024 11:00:56 +0900 Subject: [PATCH 2/5] style(prettier): run --- ISSUE_TEMPLATE.md | 12 ++++++------ PULL_REQUEST_TEMPLATE.md | 4 ++-- package-lock.json | 20 ++++++++++---------- package.json | 4 ++-- spec/keymap-manager-spec.js | 10 ++++++++-- src/keymap-manager.js | 24 ++++++++++++------------ 6 files changed, 40 insertions(+), 34 deletions(-) diff --git a/ISSUE_TEMPLATE.md b/ISSUE_TEMPLATE.md index b60bb86..bd8b5f5 100644 --- a/ISSUE_TEMPLATE.md +++ b/ISSUE_TEMPLATE.md @@ -8,12 +8,12 @@ Do you want to ask a question? Are you looking for support? The Atom message boa ### Prerequisites -* [ ] Put an X between the brackets on this line if you have done all of the following: - * Reproduced the problem in Safe Mode: http://flight-manual.atom.io/hacking-atom/sections/debugging/#using-safe-mode - * Followed all applicable steps in the debugging guide: http://flight-manual.atom.io/hacking-atom/sections/debugging/ - * Checked the FAQs on the message board for common solutions: https://discuss.atom.io/c/faq - * Checked that your issue isn't already filed: https://github.com/issues?utf8=✓&q=is%3Aissue+user%3Aatom - * Checked that there is not already an Atom package that provides the described functionality: https://atom.io/packages +- [ ] Put an X between the brackets on this line if you have done all of the following: + - Reproduced the problem in Safe Mode: http://flight-manual.atom.io/hacking-atom/sections/debugging/#using-safe-mode + - Followed all applicable steps in the debugging guide: http://flight-manual.atom.io/hacking-atom/sections/debugging/ + - Checked the FAQs on the message board for common solutions: https://discuss.atom.io/c/faq + - Checked that your issue isn't already filed: https://github.com/issues?utf8=✓&q=is%3Aissue+user%3Aatom + - Checked that there is not already an Atom package that provides the described functionality: https://atom.io/packages ### Description diff --git a/PULL_REQUEST_TEMPLATE.md b/PULL_REQUEST_TEMPLATE.md index cdaa94a..b4a55e7 100644 --- a/PULL_REQUEST_TEMPLATE.md +++ b/PULL_REQUEST_TEMPLATE.md @@ -1,7 +1,7 @@ ### Requirements -* Filling out the template is required. Any pull request that does not include enough information to be reviewed in a timely manner may be closed at the maintainers' discretion. -* All new code requires tests to ensure against regressions +- Filling out the template is required. Any pull request that does not include enough information to be reviewed in a timely manner may be closed at the maintainers' discretion. +- All new code requires tests to ensure against regressions ### Description of the Change diff --git a/package-lock.json b/package-lock.json index fc796dd..c3bff6b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -27,9 +27,9 @@ "electron-mocha": "^12.0.0", "electron-rebuild": "^3.2.9", "eslint": "^8.41.0", - "eslint-config-prettier": "^8.8.0", + "eslint-config-prettier": "^9.1.0", "lolex": "1.4.0", - "prettier": "^2.8.8", + "prettier": "^3.2.5", "rimraf": "2.2.2", "sinon": "1.17.3", "space-pencil": "0.3.0", @@ -3889,9 +3889,9 @@ } }, "node_modules/eslint-config-prettier": { - "version": "8.8.0", - "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-8.8.0.tgz", - "integrity": "sha512-wLbQiFre3tdGgpDv67NQKnJuTlcUVYHas3k+DZCc2U2BadthoEY4B7hLPvAxaqdyOGCzuLfii2fqGph10va7oA==", + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-9.1.0.tgz", + "integrity": "sha512-NSWl5BFQWEPi1j4TjVNItzYV7dZXZ+wP6I6ZhrBGpChQhZRUaElihE9uRRkcbRnNb76UMKDF3r+WTmNcGPKsqw==", "dev": true, "bin": { "eslint-config-prettier": "bin/cli.js" @@ -6447,15 +6447,15 @@ } }, "node_modules/prettier": { - "version": "2.8.8", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.8.tgz", - "integrity": "sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==", + "version": "3.2.5", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.2.5.tgz", + "integrity": "sha512-3/GWa9aOC0YeD7LUfvOG2NiDyhOWRvt1k+rcKhOuYnMY24iiCphgneUfJDyFXd6rZCAnuLBv6UeAULtrhT/F4A==", "dev": true, "bin": { - "prettier": "bin-prettier.js" + "prettier": "bin/prettier.cjs" }, "engines": { - "node": ">=10.13.0" + "node": ">=14" }, "funding": { "url": "https://github.com/prettier/prettier?sponsor=1" diff --git a/package.json b/package.json index ca1df15..823d44b 100644 --- a/package.json +++ b/package.json @@ -38,9 +38,9 @@ "electron-mocha": "^12.0.0", "electron-rebuild": "^3.2.9", "eslint": "^8.41.0", - "eslint-config-prettier": "^8.8.0", + "eslint-config-prettier": "^9.1.0", "lolex": "1.4.0", - "prettier": "^2.8.8", + "prettier": "^3.2.5", "rimraf": "2.2.2", "sinon": "1.17.3", "space-pencil": "0.3.0", diff --git a/spec/keymap-manager-spec.js b/spec/keymap-manager-spec.js index 9b3ff62..ead46a3 100644 --- a/spec/keymap-manager-spec.js +++ b/spec/keymap-manager-spec.js @@ -2184,7 +2184,10 @@ describe('KeymapManager', function () { 'ctrl-a': 'x' ` ) - keymapManager.loadKeymap(keymapFilePath, { watch: true, watchImmediately: true }) + keymapManager.loadKeymap(keymapFilePath, { + watch: true, + watchImmediately: true + }) subscription = keymapManager.watchSubscriptions[keymapFilePath] return assert.equal( keymapManager.findKeyBindings({ command: 'x' }).length, @@ -2325,7 +2328,10 @@ describe('KeymapManager', function () { assert(!reloaded) // Can start watching again after cancelling - keymapManager.loadKeymap(keymapFilePath, { watch: true, watchImmediately: true }) + keymapManager.loadKeymap(keymapFilePath, { + watch: true, + watchImmediately: true + }) fs.writeFileSync( keymapFilePath, `\ diff --git a/src/keymap-manager.js b/src/keymap-manager.js index 2d01d4b..f85969a 100644 --- a/src/keymap-manager.js +++ b/src/keymap-manager.js @@ -967,19 +967,19 @@ module.exports = KeymapManager = (function () { target != null && target !== document ) { - partialMatchCandidates = partialMatchCandidates.filter(function ( - binding - ) { - if ( - !ignoreKeystrokes.has(binding.keystrokes) && - target.webkitMatchesSelector(binding.selector) - ) { - partialMatches.push(binding) - return false - } else { - return true + partialMatchCandidates = partialMatchCandidates.filter( + function (binding) { + if ( + !ignoreKeystrokes.has(binding.keystrokes) && + target.webkitMatchesSelector(binding.selector) + ) { + partialMatches.push(binding) + return false + } else { + return true + } } - }) + ) target = target.parentElement } return partialMatches.sort((a, b) => b.keystrokeCount - a.keystrokeCount) From 9cf37066550845b0041ccf2531049d7e58637261 Mon Sep 17 00:00:00 2001 From: Takuya Matsuyama Date: Wed, 13 Mar 2024 11:03:18 +0900 Subject: [PATCH 3/5] ci(node): bump up actions --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 659107b..3d4f425 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,10 +13,10 @@ jobs: runs-on: ${{ matrix.os }} steps: - name: Checkout 🛎️ - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 + uses: actions/checkout@v4 + - uses: actions/setup-node@v4 with: - node-version: '18' + node-version: '20' - name: Install dependencies run: npm i --openssl_fips='' - name: Rebuild dependencies for Electron From 0a4c99dfd4a09ce0bf8b22acea4d2481da534345 Mon Sep 17 00:00:00 2001 From: Takuya Matsuyama Date: Wed, 13 Mar 2024 11:07:08 +0900 Subject: [PATCH 4/5] ci(node): use 21 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3d4f425..4ef53b0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,7 +16,7 @@ jobs: uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: - node-version: '20' + node-version: '21' - name: Install dependencies run: npm i --openssl_fips='' - name: Rebuild dependencies for Electron From 8eb2aaab63c6b188d576585641fab01d71e3bd6c Mon Sep 17 00:00:00 2001 From: Takuya Matsuyama Date: Wed, 13 Mar 2024 11:09:48 +0900 Subject: [PATCH 5/5] fix(ci): gyp not working --- .github/workflows/ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4ef53b0..a9206fd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,7 +16,9 @@ jobs: uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: - node-version: '21' + node-version: '20' + - if: ${{ ! startsWith(matrix.os, 'windows') }} + run: python3 -m pip install setuptools - name: Install dependencies run: npm i --openssl_fips='' - name: Rebuild dependencies for Electron