Skip to content

Plugin blocks Alt+, #736

Open
Open

Description

@dhnm

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

Activity

  1. benwiley4000 commented on Feb 12, 2020

    @benwiley4000

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

  2. benwiley4000 commented on Feb 12, 2020

    @benwiley4000

    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.

  3. benwiley4000 commented on Feb 12, 2020

    @benwiley4000

    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.
  4. SlovakianCanon commented on May 14, 2020

    @SlovakianCanon

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

  5. benwiley4000 commented on May 14, 2020

    @benwiley4000

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

  6. bevacqua commented on Mar 2, 2021

    @bevacqua

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions