Comments (8)
This is an error message that comes from to the underlying coffeescript compiler that's used in the ace coffeescript mode.
from pencilcode.
Can you be more specific?
If I type something like this, it does auto-indent on the next line:
fn = (x) ->
On Tue, Mar 11, 2014 at 1:25 AM, Weihang Fan [email protected]:
Is it intended?
Reply to this email directly or view it on GitHubhttps://github.com//issues/43
.
from pencilcode.
It does not indent for statements such as if and for, which is (I think) caused by editor.setBehavioursEnabled(false) in line 1249 in editor_view.js.
from pencilcode.
Does that really do autoindenting in CoffeeScript? If I remember correctly, I found the BehaviorsEnabled flag really annoying for HTML documents where the autoindenting was too aggressive. Can you test it on a branch and see how it behaves?
from pencilcode.
It turns out that the code in ACE responsible identifying lines for autoindenting is line 53 in https://github.com/ajaxorg/ace/blob/master/lib/ace/mode/coffee.js. However, I can't understand this blob of regex enough to fix it.
from pencilcode.
Here is the regexp disassembled, perlre /x style:
/(?: [({[=:] # Opening parentheses or brackets |[-=]> # OR single or double arrow |\b(?: # OR one of these words: else # else |switch # OR switch |try # OR try |catch # OR catch, optionally followed by: (?:\s*[$A-Za-z_\x7f-\uffff][$\w\x7f-\uffff]*)? # a variable |finally # OR finally ))\s*$/ # all as the last thing on a line (allowing trailing space)
Here is a possible modification:
/(?: [({[=:] # Opening parentheses or brackets |[-=]> # OR single or double arrow |\b(?: # OR one of these words: else # else |switch # OR switch |try # OR try |catch # OR catch, optionally followed by: (?:\s*[$A-Za-z_\x7f-\uffff][$\w\x7f-\uffff]*)? # a variable |finally # OR finally ))\s*$ # all as the last thing on a line (allowing trailing space) | # ---- OR ---- some new stuff: ^\s* # a line starting with optional space (else\b\s*)? # followed by an optional "else" (?: # followed by one of the following: if # if |for # OR for |while # OR while |loop # OR loop )\b # (as a word) (?!.*\bthen\b) # ... but NOT followed by "then" on the line /
In other words (without spaces or comments):
/(?:[({[=:]|[-=]>|\b(?:else|switch|try|catch(?:\s*[$A-Za-z_\x7f-\uffff][$\w\x7f-\uffff]*)?|finally))\s*$|^\s*(else\b\s*)?(?:if|for|while|loop)\b(?!.*\bthen\b)/
If you test this (or something like it) and it works, you should try to push it to ace upstream, and we can patch it to our fork of ace.
from pencilcode.
Frank - can I also ask you to patch it in to this repo? It's the specific fork of ace we're using for Pencil Code.
https://github.com/PencilCode/pencilcode-ace
from pencilcode.
Seems fixed.
from pencilcode.
Related Issues (20)
- Not working properly in mobile HOT 1
- Email button not working HOT 3
- p5.js not working? HOT 1
- Don't return placeholder HTML for non-existing .js files
- Feature Request: API for "create new file with starter code"
- UX: Blocks mode activates keyboard too often on mobile device
- Pencil Code Embed: setCode also resets palette.
- File icon is not saved if it's a new file
- Custom Block Palette: inconsistent behavior about multi-line snippets HOT 1
- trying to install pencil code at my server and getting ERROR when run GRUNT HOT 3
- how to integrate g+ into pencilcode
- error [email protected] install: `node-gyp configure build HOT 1
- I can't install pencilcode. please help!
- How to insert new block?
- Thumbnail popover is a bit misaligned when a new thumbnail is created
- Something worng when run grunt HOT 1
- Blocks for adding elements to array
- Custom palette using guide requires user be logged in, making link sharing difficult
- Unable to type properly on mobile devices
- Error while running grunt HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pencilcode.