jbaron / cats

Code Assistant for TypeScript
Apache License 2.0
408 stars 66 forks source link

CMD+W should close a tab and not whole cats an OS X #130

Closed alexwall closed 9 years ago

alexwall commented 9 years ago

Hi, if I have more than one tab in Safari, CMD+W closes the active tab If I have just one tab, it closes the active window, but Safari keeps still open. I tested this on diffrent systems and found this resources:

http://www.tuaw.com/2013/11/29/mac-101-an-introduction-to-keyboard-shortcuts-in-safari-for-mac/ http://www.dori.com/safariShortcuts.html

The CMD+W short cut also close tabs in Intellij, Eclipse and other IDE's or Text Editors like TextMate and Sublime.

Bye, Alex

jbaron commented 9 years ago

I the latest checkin I added basic support for shortcuts. As a test I used your test case, so CMD-W now closes a tab.

However still a lot to be done to: 1) Make it cross platform 2) More generic/user configurable

So will add this to the todo list

fasterthanlime commented 9 years ago

@jbaron you can take a look in https://github.com/fasterthanlime/cats/tree/better-shortcuts, I've added more default shortcuts, made it "cross-platform" (Meta on OSX vs Ctrl everywhere else).

Now I'm dreaming of a quick open dialog that does fuzzy matching on the filePaths of the opened project. That would've been useful so many times in the past weeks. Does it sound interesting?

jbaron commented 9 years ago

My idea was to have "three sections" in the shortcuts file (one per each OS: OSX, Win, Linux) and load the one for the OS currently used. That way different OS’es can have different shortcuts (not only meta versus control). That would give a bit more flexibility.

Regarding the quick open, do you mean you want to be able to open all files that match lets say "dialog*.ts”. Or is it something else you are looking for?

P.S There is a feature to reopen the files that were last time open. Not sure if still correct, but that might be also useful if you every time work on the same files.

On 29 Dec 2014, at 23:07, Amos Wenger notifications@github.com wrote:

@jbaron https://github.com/jbaron you can take a look in https://github.com/fasterthanlime/cats/tree/better-shortcuts https://github.com/fasterthanlime/cats/tree/better-shortcuts, I've added more default shortcuts, made it "cross-platform" (Meta on OSX vs Ctrl everywhere else).

Now I'm dreaming of a quick open dialog that does fuzzy matching on the filePaths of the opened project. That would've been useful so many times in the past weeks. Does it sound interesting?

— Reply to this email directly or view it on GitHub https://github.com/jbaron/cats/issues/130#issuecomment-68308682.

fasterthanlime commented 9 years ago

Well, the project I'm working on right now has 220+ typescript files, so I'm not always working on the same 4-5 tabs. Hence the need to be able to quickly open any given file. I have two main ways of doing that:

Mostly I'd like to replicate TextMate's Cmd-T feature. You can see a video of a similar vim plugin here: https://www.youtube.com/watch?v=zprB9KDyaME

The workflow goes: "Cmd-T", "type a few letters of the file" (even with typos, bad casing, etc.), the file list updates in real time (number of matches narrows down), one can navigate up/down with the keyboard and press "Enter" to open the file in a new tab (or switch to it if it's already open), or press "Esc" to cancel the quick open.

I think it would be a bit of a challenge to do that in Qooxdoo, but not impossible. The big upside, to me is to be able to quickly open any file of the project without having to lift fingers from the keyboard.

Ninja edit: regarding the "different shortcut sets per platform" rather than "automatically using Meta- or Ctrl-", I'll go in that direction in my branch and see if that's coherent with your plans!

fasterthanlime commented 9 years ago

In fact, a contrib Qooxdoo component named ComboTable seems to do pretty much exactly what I had in mind: http://demo.qooxdoo.org/contrib/demobrowser/#ComboTable~trunk%2Fdefault%2F1.4.2%2Findex.html

The only problem being that it seems to be for a legacy version of Qooxdoo.. but hopefully it can be ported without too many problems.

fasterthanlime commented 9 years ago

Regarding the quick open, do you mean you want to be able to open all files that match lets say "dialog*.ts”. Or is it something else you are looking for?

About matching: there's a nice little JS library called Fuse that does fuzzy matching pretty well. If you don't want to bring in an external dependency, we could probably cook up something using the Levenshtein distance between the search term & the candidate strings, but it might get pretty slow for big projects, wheras Fuse uses a variant of Google's diff-match-patch to remain efficient on a mid-size corpus.

Oh, and to answer that question more particularly: I'm only looking to open a single file at a time. Just to to do it in the minimum amount of keystrokes/human interaction.

fasterthanlime commented 9 years ago

Opened #138 to track 'Quick open', back to the keyboard shortcut matter:

The reason I went with Ctrl/Cmd automatic handling is because I feel like most shortcuts will be shared across platforms, and it would be a pain to maintain 3 copies of what is basically the same data. But maybe you have counter-examples in mind that would make it clear why it's better to have separate shortcut-sets.

Edit: nevermind, realized you answered all of those in your original comment...

fasterthanlime commented 9 years ago

@jbaron I guess this issue has been addressed and can be closed then? Or are you only closing issues when the changes land in master/stable release?

jbaron commented 9 years ago

Now shortcuts are supported per platform in latest unstable release

jbaron commented 9 years ago

Since all development now is done on the unstable branch, I do close issues that are only fixed on the unstable branch. However the idea is too soon merge unstable into the master branch (only problem is that the TypeScript services should be a bit more stable than they are right now).

So I indeed I just closed this issue (and the one about quick open, since that is now also available).

On 30 Dec 2014, at 22:39, Amos Wenger notifications@github.com wrote:

@jbaron https://github.com/jbaron I guess this issue has been addressed and can be closed then? Or are you only closing issues when the changes land in master/stable release?

— Reply to this email directly or view it on GitHub https://github.com/jbaron/cats/issues/130#issuecomment-68401423.

fasterthanlime commented 9 years ago

Makes sense, thank for the explanation.

I realize the TypeScript services aren't always the stablest of beasts, but right now it seems CATS is the only editor that supports recent TS versions properly! Vim & Textmate support are lagging behind, mostly because of https://github.com/clausreinke/typescript-tools/issues/39.

Btw, I did notice the version bump in the .nw file on this page: https://github.com/jbaron/cats/releases — maybe it would be possible to update the release notes as well? Quick open would make for a nice screenshot imho, and mentioning Linux compatibility (prompt/confirm dialogs) might help reassure some returning users. Just a suggestion though, I know you've got a lot on your plate :)