Some comment styles in a block break break in Sublime Text 2

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

For example, consider this 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'); } 

Re-enabling the entire unit should result in the following:

 $(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 as follows:

 $(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'); } 

While a C-style single-line comment appears, it and the line following it are indented. Regardless of the order in which other comments appear, not one of them, nor the lines following them get indented.

The real problem here is that the indentation is not only discarded in these comments, but also violates any indentation that usually works after the comment. Using the Reindent command on every single line, even comments, backtrack them properly.

Any tips on this behavior?

+6
source share

Source: https://habr.com/ru/post/945629/


All Articles