ballerina-platform / ballerina-lang

The Ballerina Programming Language
https://ballerina.io/
Apache License 2.0
3.58k stars 737 forks source link

Add required fields completion item for mapping contructor is not formatted correctly #33701

Open malinthar opened 2 years ago

malinthar commented 2 years ago

Description: Consider the following screen capture capture

The text edit of the above completion item is as follows. text edit

The text edit should be formatted as follows. formatted

malinthar commented 1 year ago

The number of cases to consider is overwhelming.

For example following are some of the cases.

type MyRecord record {|
    string name;
    int age;
    string job;
|};

public function main() {
    MyRecord rec = {age: 0, job: "doctor", <cursor>};

    MyRecord rec2 = {<cursor>}

    rec = {
        <cursor>
    }

    rec = {
        age: 0,
        <cursor>
        job: "doctor"
    };

    rec = {
    age: 0,
    <cursro>
    };

    test({name: "", age: 0});
}

function test(MyRecord rec) {

}

IMHO, it is best not to include the formatting logic in the text edit of the completion item. The users can use the Ballerina formatter to format the file or a selected range. Therefore, we can deprioritize this issue for the moment.