sublimehq / Packages

Syntax highlighting files shipped with Sublime Text and Sublime Merge
https://sublimetext.com
Other
2.95k stars 586 forks source link

[JavaScript] Indentation rules trigger in mapping objects #3747

Open rchl opened 1 year ago

rchl commented 1 year ago

Typing default as the key name in an object triggers dedent:

Expected behavior

const x = {
    default|
}

Actual behavior

const x = {
default|
}

Steps to reproduce

Write default inside an object:

const x = {
    default
}

The scopes are source.js meta.mapping.js in this location so I guess dedent rules could exclude meta.mapping but then it would also disable it in code like:

const x = {
    default() {
        switch (x) {
            default|
        }
    }
}
Thom1729 commented 1 year ago

It seems like the easy fix would be replacing the default\b pattern in the indent rules with something like default:\b (and perhaps something similar for case). I'm not that familiar with the indent rules, though.

EDIT: never mind, that obviously would not solve the problem.

Thom1729 commented 1 year ago

Solving this via scoping would be tricky due to https://github.com/sublimehq/sublime_text/issues/2152.