mardi 29 avril 2014

sublimetext2 - certains styles de commentaire dans un bloc Rodez les re-indentation Sublime texte 2 - Stack Overflow


In Sublime Text 2, re-indentation (Edit -> Line -> Reindent)seems to bug out in the presence of certain comment styles in Javascript code. Only single-line C-style comments (/* ... */)work properly.


For example, consider this un-indented code:


$(window).load(function () {
/* Single-line C-style comment */
var $player = $('#player');
/* Multiple-line
C-style comment */
var $player = $('#player');
// Single-line C++-style comment
var $player = $('#player');
// Multiple-line
// C++-style comment
var $player = $('#player');
}

Reindenting the entire block should result in this:


$(window).load(function () {
/* Single-line C-style comment */
var $player = $('#player');
/* Multiple-line
C-style comment */
var $player = $('#player');
// Single-line C++-style comment
var $player = $('#player');
// Multiple-line
// C++-style comment
var $player = $('#player');
}

Instead, it ends up like this:


$(window).load(function () {
/* Single-line C-style comment */
var $player = $('#player');
/* Multiple-line
C-style comment */
var $player = $('#player');
// Single-line C++-style comment
var $player = $('#player');
// Multiple-line
// C++-style comment
var $player = $('#player');
}

As long as the single-line C-style comment appears first, it and the line following it both get indented. No matter what order the other comments appear in, none of them, nor the lines following them, receive indentation.


The real problem here is that not only does the indentation fail on those comments, but they also break any indentation that would normally work following the comment. Using the Reindent command on each individual line, even the comments, indents them properly.


Any clues on this behavior?



In Sublime Text 2, re-indentation (Edit -> Line -> Reindent)seems to bug out in the presence of certain comment styles in Javascript code. Only single-line C-style comments (/* ... */)work properly.


For example, consider this un-indented code:


$(window).load(function () {
/* Single-line C-style comment */
var $player = $('#player');
/* Multiple-line
C-style comment */
var $player = $('#player');
// Single-line C++-style comment
var $player = $('#player');
// Multiple-line
// C++-style comment
var $player = $('#player');
}

Reindenting the entire block should result in this:


$(window).load(function () {
/* Single-line C-style comment */
var $player = $('#player');
/* Multiple-line
C-style comment */
var $player = $('#player');
// Single-line C++-style comment
var $player = $('#player');
// Multiple-line
// C++-style comment
var $player = $('#player');
}

Instead, it ends up like this:


$(window).load(function () {
/* Single-line C-style comment */
var $player = $('#player');
/* Multiple-line
C-style comment */
var $player = $('#player');
// Single-line C++-style comment
var $player = $('#player');
// Multiple-line
// C++-style comment
var $player = $('#player');
}

As long as the single-line C-style comment appears first, it and the line following it both get indented. No matter what order the other comments appear in, none of them, nor the lines following them, receive indentation.


The real problem here is that not only does the indentation fail on those comments, but they also break any indentation that would normally work following the comment. Using the Reindent command on each individual line, even the comments, indents them properly.


Any clues on this behavior?


0 commentaires:

Enregistrer un commentaire