dart-atom / dart

A Dart plugin for Atom.
http://dart-atom.github.io/dart/
BSD 3-Clause "New" or "Revised" License
154 stars 44 forks source link

Automatic source injection heuristics need improvement #1064

Open lukechurch opened 8 years ago

lukechurch commented 8 years ago

Text editing at the moment frequently results in changes being made to the source code that introduce new errors. A reasonable heuristic is that additional characters should not be automatically injected into the code if they create an error where there wasn't one before.

For example


/*  =======================================

This is a marker 

*/

If you place the cursor after the '/*' and before the '======' and press enter the following is created:

/*  
 * 
 */=======================================

This is a marker 

*/

This is no longer valid dart code, and the user has to repair the results of the injection being helpful. If the above heuristic was applied it would result in

/*  
 * =======================================

This is a marker 

*/

The same strategy should be applied to automatic injection of parentheses, braces etc. It isn't a perfect heuristic but it is better than the current interaction flow.