Skip to content

sw6ueyz/FixSmartIndent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

What is this ?

In javascript/typescript editor, if you disable auto formatting and enable smart indent, braces ({}) does not correctly dedents.

See :

https://developercommunity.visualstudio.com/t/closing-brace-does-not-dedent-in-javascr/1110276

It looks like they decided not to fix the problem even in VS2022, so I made a simple patch myself.

This program was created for personal use, but I am sharing it because there may be others who are annoyed by the same problem.

How to use ?

This program just fixes the following problem and does not have any settings.

When you disable auto formatting and enable smart indent in IDE editor,

before fix :

if ( true ) {           // line ends with '{'.
    someCode();
    }                   // pressing '}' does not dedent properly.

after fix :

if ( true ) {
    someCode();
}                       // pressing '}' now dedents.

This triggers only if you press '}' and its matching '{' appears at the end of one of the previous lines.

It also recognizes nested parentheses or string literals :

    if ( true &&
        "})\"" ) {
    }
//  ^                   pressing '}' dedents to here

In version 1.1, following fix is added :

class Test
    {              // pressing '{' does not dedent properly.

after fix :

class Test
{                  // pressing '{' now dedents.

In version 1.2, this extension triggers in only .ts, .js, .mjs, .cjs, .mts, .cts files.

Notice

Please notify me if they fix the bug in Visual Studio. I'll happly remove this program from here.

source code :

https://github.com/sw6ueyz/FixSmartIndent

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages