language-ethereum
language-ethereum copied to clipboard
Indentation error when event/function args are on multiple lines
I am using Atom 1.23.2 x64 on the latest Windows 10, writing in Solidity in a file with a .sol extension. The code below, written as an illustrative example, is presented as Atom auto-indents it, with four spaces per indent for visual clarity:
pragma solidity ^0.4.0;
contract Recorder {
struct Data {
uint timestamp;
uint score;
string name;
}
event RecordUpdated (
uint previousTimeStamp, uint newTimestamp,
uint previousScore, uint newScore,
string previousName, string newName
); //Adds first level of extra indentation
function updateRecord( //newline or space or nothing before open makes no difference
uint newTimestamp,
uint newScore,
string newName
) public { //Adds second level of extra indentation
RecordUpdated (
timestamp, newTimestamp,
score, newScore,
name, newName
); //Adds 3rd level. Bringing this up a line does not help.
timestamp = newTimestamp;
score = newScore;
name = newName;
}
}
//Any further code starts three levels indented.
//The indentation errors accumulate quickly.
Here is the expected indentation, removing/changing comments that don't affect indentation. I have not found a workaround other than fixing this manually:
pragma solidity ^0.4.0;
contract Recorder {
struct Data {
uint timestamp;
uint score;
string name;
}
event RecordUpdated (
uint previousTimeStamp, uint newTimestamp,
uint previousScore, uint newScore,
string previousName, string newName
);
function updateRecord (
uint newTimestamp,
uint newScore,
string newName
) public {
RecordUpdated (
timestamp, newTimestamp,
score, newScore,
name, newName
);
timestamp = newTimestamp;
score = newScore;
name = newName;
}
}
//Any further code should start flush with the left.
//The indentation errors should not accumulate.