You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Dec 15, 2022. It is now read-only.
I am using Atom 1.23.2 x64 on the latest Windows 10, writing in Javascript in a file with a .js extension.
The code below, written as an illustrative example, is presented as Atom auto-indents it, with four spaces per indent for visual clarity:
function workaround1(param1, message, extra, beyond) {
var starter = doSomeFormatting(param1,
{message: "hardcoded",
information: extra,
more: beyond}
);
var a = 4;
var b = 5;
return add(a,b);
}
function workaround2(param1, message, extra, beyond) {
var tempObject = {
message: "hardcoded",
information: extra,
more: beyond,
};
var starter = doSomeFormatting(param1, tempObject);
var a = 4;
var b = 5;
return add(a,b);
}
function workaround3(param1, message, extra, beyond) {
var tempObject = {};
tempObject.message = message,
tempObject.information = extra,
tempObject.more: beyond,
var starter = doSomeFormatting(param1, tempObject);
var a = 4;
var b = 5;
return add(a,b);
}
function unexpected1(param1, message, extra, beyond) {
var starter = doSomeFormatting(param1,
{information: extra,
message: "hardcoded",
more: beyond}
);
var a = 4;
var b = 5;
return add(a,b);
}
function unexpected2(param1, message, extra, beyond) {
var starter = doSomeFormatting(param1,
{message: message,
information: extra,
more: "beyond"}
);
var a = 4;
var b = 5;
return add(a,b);
}
function unexpected3(param1, message, extra, beyond) {
var starter = doSomeFormatting(param1,
{message: message,
information: extra,
more: beyond}
);
var a = 4;
var b = 5;
return add(a,b);
}
function add(first, second) {
return first + second;
}
function subtract(first, second) {
return first - second;
}
//Any further code starts three levels indented.
//The indentation errors accumulate quickly.
The functions named workaround# show the expected formatting.
The difference between workaround1 and unexpected1 which triggers an indentation error in the latter is that the first element of the object being passed in as the second parameter is a variable, not a hard-coded string.
Unfortunately, the workaround of reordering the fields in the object does not work for the case of unexpected3, in which all of the fields are variables. That's the case which led me to find this bug.
Auto-indentation should not change behavior when a variable is used in place of a hard-coded string for the value of the first field in a JavaScript object passed as a parameter to a function.
From @wbt on February 12, 2018 18:52
I am using Atom 1.23.2 x64 on the latest Windows 10, writing in Javascript in a file with a .js extension.
The code below, written as an illustrative example, is presented as Atom auto-indents it, with four spaces per indent for visual clarity:
The functions named
workaround#
show the expected formatting.The difference between
workaround1
andunexpected1
which triggers an indentation error in the latter is that the first element of the object being passed in as the second parameter is a variable, not a hard-coded string.Unfortunately, the workaround of reordering the fields in the object does not work for the case of
unexpected3
, in which all of the fields are variables. That's the case which led me to find this bug.Auto-indentation should not change behavior when a variable is used in place of a hard-coded string for the value of the first field in a JavaScript object passed as a parameter to a function.
Copied from original issue: atom/atom#16720
The text was updated successfully, but these errors were encountered: