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

keyboard shortcut doesn't work #21

Open
UnsungHero97 opened this issue Nov 28, 2019 · 0 comments
Open

keyboard shortcut doesn't work #21

UnsungHero97 opened this issue Nov 28, 2019 · 0 comments

Comments

@UnsungHero97
Copy link

(Apologies. I originally posted this issue in the wrong repo; moving renke/import-sort#105 here.)

Atom v1.41.0
atom-import-sort v6.0.0

The "Sort on save" option works as expected, but I can't seem to be able to use the keyboard shortcut to activate the import-sort:sort command. Defining a custom keyboard shortcut in my keymap.cson also doesn't trigger sorting.

UPDATE

I was able to get this working by modifying the package source code locally. This selector seems problematic:

https://github.com/renke/atom-import-sort/blob/master/src/index.ts#L38

'atom-text-editor[data-grammar~="source"][data-grammar~="js"],atom-text-editor[data-grammar~="source"][data-grammar~="ts"]',

I changed the selector to just 'atom-text-editor', added a custom keyboard shortcut, and it worked.

// ~/.atom/packages/atom-import-sort/lib/index.js
atom.commands.add(
  'atom-text-editor', 
  "import-sort:sort", 
  () => this.sortCurrentEditor()
);
'atom-text-editor':
  'ctrl-alt-i': 'import-sort:sort'
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

1 participant