-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Add tab key usage to try-it editor #3342
Conversation
Try the demo here: http://zombiehippie.github.io/coffee-script/ |
e.preventDefault() | ||
textbox = e.target | ||
# Insert tab character at caret or in selection | ||
textbox.value = textbox.value[0...textbox.selectionStart] + "\t" + textbox.value[textbox.selectionEnd...] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd strongly prefer " "
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd strongly prefer " "
Why?
I guess I'd prefer "\t"
because it will be preserved when you copy-paste it.
But it would be a better idea to go all the way and use CodeMirror (if Ace is not an option), as mentioned in other issue. |
Well considering the time it takes to implement CodeMirror, this is a great quick addition. |
@zombiehippie It did make the textarea lose focus. 2 spaces are preferred indentation style for CS (judging from its compiler and unofficial style guide). |
why isn't Ace an option? |
@xixixao we could have a checkbox "Use tabs" @rlidwka Ace is definitely an option, but if I were implementing this I would use CodeMirror, which is a lot smaller library, because I use it a lot and know it has great documentation (not to say Ace doesn't also) Plus CodeMirror v4 is going to have multiselection) After tweaking the styles and functions of CodeMirror to my liking, I've found there to be little difference between Ace and CodeMirror (besides multiselect obv.) In fact I've already made a coffeescript try it editor with codemirror that you can try and see the src of. ZombieHippie/Quick-Test-CoffeeScript/gh-pages It would be optimal if the ide had a "Use-tabs" option also. |
@zombiehippie Finally, this makes CodeMirror viable again! Definitely no option and if beginner is visiting they should definitely be introduced to the correct style. 2 spaces, no guesses there. If you want to change tab style you should be using some better deployment of the editors or a desktop editor. |
When I press "tab", I usually expect "tab", not two spaces. If you want indent width to be equal to 2 spaces, that's fine, just set |
I don't know what else I can argue here. I suspect that the over hundred contributors to this project have mostly used the |
@xixixao I guess someone could just convert indentation to spaces, check their syntax/experiment, and then convert back to tabs if they wanted. That is a easy to use feature of Sublime Text. I personally use tab indentation for every project I have, I obviously would not be benefitted by having abother CodeMirror/Ace editor that doesn't support the tab char. |
@xixixao oh! What if the default behaviour of the tab key was two spaces, and then shift+tab was the tab character? |
|
@xixixao Triple check CM4 for syntax highlighting issues. That's the one thing that prevents me from implementing it into my occupational projects. I highly recommend looking at how I implemented CodeMirror to save you some time! CTRL+] and CTRL+[ for indentation is supported also as demonstrated on most every editor ST, Ace, CM, etc. |
Would be cool if CM4 was lazy loaded ;). I don't want it on mobile view, it'd hurt too much |
Are there any plans to implement something like this? I usually go to the coffeescript site when testing random quick things, and I usually have a moment of confusion when tab doesn't do what I expect it to do. |
* The generated JavaScript for the examples in the docs ends up within index.html, so we don’t need the intermediate generated .js files committed in the repo; also, even while .gitignored they should be under `docs`, with the rest of the generated files, not under `documentation`, where the source files are. * Add “Existential Operator” to the table of contents. Closes #4361 * Updated output due to newer version of highlight.js * Generated the JavaScript for the docs examples should be synchronous, so that index.html isn’t generated before the JavaScript is * In “Try CoffeeScript,” if you press the tab key it should type a tab character. Closes #3342. * Rename doc example folders from `js` and `coffee` to just `examples` * Add missing `yield` to the list of keywords to highlight until highlight.js catches up; update the class used to match highlight.js’ `keyword` * `cake doc:site` should watch the example files too, not just index.html.js * Remove examples folder, including underscore.coffee; remove link to annotated underscore.coffee
Use the tab character in the try-it editor's textbox