Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin blocks Alt+, #736

Open
dhnm opened this issue Nov 29, 2019 · 6 comments
Open

Plugin blocks Alt+, #736

dhnm opened this issue Nov 29, 2019 · 6 comments

Comments

@dhnm
Copy link

dhnm commented Nov 29, 2019

When Alt+, is pressed, typescript_signature_popup command is called, preventing me from typing < symbol on QWERTZ keyboard.

@benwiley4000
Copy link

I have the same issue. @rouxfeur did you find a workaround? This prevents me from using this plugin with Sublime.

@benwiley4000
Copy link

benwiley4000 commented Feb 12, 2020

This problem is not just for QWERTZ, it also exists for QWERTY Canadian Multilingual layout (English+French), which is used for any "Canadian French language" Mac keyboard.

@benwiley4000
Copy link

I do have a workaround which is to comment out that shortcut from the keyboard shortcuts file in the package source directory.

  1. Open the file (on macOS it's at ~/Library/Application\ Support/Sublime\ Text\ 3/Packages/TypeScript/Default.sublime-keymap)
  2. Go to line 130 and comment out the rule for "alt+,":
    },    // In case when auto match is enabled, only format if not within {}
    // {
    //     "keys": [ "alt+,"],
    //     "command": "typescript_signature_popup",
    //     "context": [
    //         { "key": "selector", "operator": "equal", "operand": "source.ts, source.tsx, source.js, source.jsx" },
    //         { "key": "tooltip_supported", "operator": "equal", "operand": true}
    
    //     ]
    // },
    {
  3. Save and restart Sublime.

@SlovakianCanon
Copy link

Spent so much time trying to figure this out, it should really be addressed. The workaround by @benwiley4000 does work until then.

@benwiley4000
Copy link

@SlovakianCanon yep, it came back for me today because my workaround gets overwritten every time the plugin updates.

@bevacqua
Copy link

bevacqua commented Mar 2, 2021

Wrote this script to fix this automatically from my zshfiles because this issue is the worst. It overwrites the keymap file, stripping the alt+, shortcut

const fs = require('fs')

tryOrExit(main)

function main() {
  const [keymapFile] = process.argv.slice(2)

  const keymapJson = readFileOrExit(keymapFile)

  // strip comments 🤷‍♂️
  const keymapStripped = keymapJson.replace(/\/\/.*/mg, '')

  const keymap = parseJsonOrExit(keymapStripped)

  const nextKeymap = getNextKeymap(keymap)
  const nextKeymapJson = JSON.stringify(nextKeymap, null, 2)

  writeFileOrExit(keymapFile, nextKeymapJson + '\n')
}

function readFileOrExit(file) {
  return tryOrExit(() => fs.readFileSync(file, 'utf8'))
}

function writeFileOrExit(file, contents) {
  return tryOrExit(() => fs.writeFileSync(file, contents, 'utf8'))
}

function parseJsonOrExit(json) {
  return tryOrExit(() => JSON.parse(json))
}

function getNextKeymap(keymap) {
  return keymap.filter(definition => (
    !Array.isArray(definition.keys) ||
    definition.keys.length !== 1 ||
    definition.keys[0] !== 'alt+,'
  ))
}

function tryOrExit(fn) {
  try {
    return fn()
  } catch (_err) {
    // rule of silence
    process.exit(0)
  }
}

Usage:

node hacks/autofix-sublime-typescript-plugin ~/Library/Application\ Support/Sublime\ Text\ 3/Packages/TypeScript/Default.sublime-keymap

Example: bevacqua/dotfiles@585dfdd

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

No branches or pull requests

4 participants