Comments (16)
The JavaScript parser doesn't do automatic semicolon insertion, and won't properly indent code with semicolons missing.
from codemirror-v1.
This seems strange, because from the language point of view missing semicolons is ok, even for ECMAScript 5. If javascript standard-makers allow missing semicolon, why codemirror doesn't handle it...
from codemirror-v1.
Feel free to implement this.
from codemirror-v1.
Does that seem difficult?
from codemirror-v1.
It's not easy, semicolon insertion is specified to happen on a parse error, and parse errors are not well-defined in CodeMirror's JavaScript parser---it typically just skips tokens it doesn't recognize.
from codemirror-v1.
I tried to switch to "shift" indentation with tab and sighed with relief, but that didn't help.
When I type "var a" and press enter, new line is indented the wrong way. Is there any way to fix it somehow?
I spent quite a lot of time making codemirror play really well with my site, is there anything I can do besides rewriting tokenizer ?
from codemirror-v1.
You do realize that if you've only typed 'var a', there is no way for the editor to know whether the next line will continue with '= 10' or with 'var b ...', right?
Apart from getting used to inserting proper semicolons, you could try commenting out the 'this.indentAtCursor()' line under the '// enter' case in the keydown handler. If that suits your need, I can make it an option.
from codemirror-v1.
This may be useful here: I just added an enterMode option, that you can set to "flat" or "keep" to override the way new lines are indented. See the manual for details.
from codemirror-v1.
Thanks, I'll give it a roll right now.
from codemirror-v1.
BTW, I gave this issue a thought and decided to put semicolons for now, because indentation is really nice thing. Just disabling it does not make editor look cool enough ;)
from codemirror-v1.
Unfortunately, there is still a problem.
E.g.
function User() { this.setName = function(name) { this.name = name; } }
This syntax is ok. But codemirror requires one more ; after function. It's just too much to be sane and convinient ;(
from codemirror-v1.
An assignment is a regular statement requiring a semicolon. Since CodeMirror does not do automatic semicolon insertion, it does not currently handle what you have. Though if you upgrade to the development snapshot, I guess (though I am not sure) that it will be handled correctly.
from codemirror-v1.
I updated to lates git. Please check this screenshot, it tells what I mean: http://img251.imageshack.us/img251/2503/ss20100826224040.png
from codemirror-v1.
Yes, I see. It will now indent lines after this one correctly, but still mess up at the semicolon insertion point. There is no easy way to handle this. If you need proper semicolon insertion, you'll have to implement it yourself.
from codemirror-v1.
Do I get it right that the only way to edit:
var func = function() { ... } ...
without indentation problems is disabling auto-indent ?
from codemirror-v1.
Correct.
from codemirror-v1.
Related Issues (20)
- Autocomplete HOT 4
- PHP Parser fails for some comments HOT 1
- C# parser problem with verbatim string HOT 1
- CodeMirror enterMode config param seems to be ignored if height is set. HOT 1
- Implement electric characters HOT 1
- lostundo missing reference in undo.js HOT 1
- Uncaught ReferenceError: lostundo is not defined HOT 1
- rewrite scrollToNode to just insert a node and check its coords if it needs to
- C# parser : bug with operators (fix inside) HOT 1
- this.editor is undefined (codemirror.js row 203) HOT 1
- content does not show HOT 9
- Liquid Mode for Codemirror2 HOT 6
- setValue() clears undo history HOT 1
- HTML5 required attribute breaks hack for form submission HOT 6
- Speed up hideLine method HOT 1
- Pressing tab causes entire line to indent HOT 4
- unable to get separate history for multiple instances of codemirror HOT 4
- loadmode plugin does not work over non string modes HOT 1
- codemirror
- Mirror Demes
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 codemirror-v1.