FIXED: [14.90b1] Format document is a mess

Post bug reports when testing beta versions here.
Post Reply
User avatar
pjj
Posts: 1872
Joined: 13 Oct 2009 13:48
Location: Kraków, Poland

FIXED: [14.90b1] Format document is a mess

Post by pjj »

Formating PHP document via new LSP function destroys it completely :cry:
E.g. from this

Code: Select all

function showReferral(string $id): void
{
    global $thisParticipantReferrals;
//    global $implementersDB;
//    global $iProfessionsDB;
this is produced:

Code: Select all

    function showReferral(str
    ing $id): voidglobal $thi

    sParticipantRef        errals;
            
    //    global $implementersDB;
Wouldn't call it helpful 8)
Alium tibi quaere fratrem; hic, quem tuum putas, meus est. Titus Flāvius Caesar Vespasiānus Augustus

User avatar
Rickard Johansson
Site Admin
Posts: 6108
Joined: 19 Jul 2006 14:29

Re: [14.90b1] Format document is a mess

Post by Rickard Johansson »

It seems some servers are very helpful and send the changes that should be made to the document from the end of document to the beginning. Which is the best way to make the changes to the document.

Other servers add the changes from top to bottom. Which means I have to reverse the order and process the list backwards.

I just have to check the list to determine what to do 8) I'll fix it in the next release...

User avatar
pjj
Posts: 1872
Joined: 13 Oct 2009 13:48
Location: Kraków, Poland

Re: [14.90b1] Format document is a mess

Post by pjj »

I should have mentioned I used Intelephense server for PHP. I might add that I never use any tool to automatically format code (with slight exception of un-minifying JavaScript once in a blue moon, but that's it.) If you prefer to postpone fixing this, I won't bat an eye 8)
Alium tibi quaere fratrem; hic, quem tuum putas, meus est. Titus Flāvius Caesar Vespasiānus Augustus

User avatar
Rickard Johansson
Site Admin
Posts: 6108
Joined: 19 Jul 2006 14:29

Re: [14.90b1] Format document is a mess

Post by Rickard Johansson »

It's been fixed. Thanks!

User avatar
pjj
Posts: 1872
Joined: 13 Oct 2009 13:48
Location: Kraków, Poland

Re: FIXED: [14.90b1] Format document is a mess

Post by pjj »

In the second beta it does the job just fine, great! However, it seems that it works only when entire document is selected -- which is confusing...

Small nitpick: "Insert spaces (instead of not tabs)" has superfluous "not", hasn't it?

And while I'm in the nitpicking mood : Project > Configuration > LSP > buttons at the bottom: if the first one is "start", the second should be "stop" 8) (cf. ApacheMonitor.exe) .
Alium tibi quaere fratrem; hic, quem tuum putas, meus est. Titus Flāvius Caesar Vespasiānus Augustus

User avatar
Rickard Johansson
Site Admin
Posts: 6108
Joined: 19 Jul 2006 14:29

Re: FIXED: [14.90b1] Format document is a mess

Post by Rickard Johansson »

There may be a bug in the language server. It works properly in other servers I've tested.

If I send a "textDocument/formatting" request to the server - I receive the response:

{"jsonrpc":"2.0","id":54,"result":[{"range":{"start":{"line":12,"character":28},"end":{"line":14,"character":2}},"newText":"\n"}]}

But if I send a "textDocument/rangeFormatting" request with the entire document selected - I receive the response:

{"jsonrpc":"2.0","id":55,"result":[{"range":{"start":{"line":11,"character":12},"end":{"line":12,"character":0}},"newText":"\n"},{"range":{"start":{"line":10,"character":28},"end":{"line":11,"character":0}},"newText":"\n"},{"range":{"start":{"line":9,"character":23},"end":{"line":10,"character":0}},"newText":"\n"},{"range":{"start":{"line":8,"character":19},"end":{"line":9,"character":2}},"newText":"\n"},{"range":{"start":{"line":6,"character":1},"end":{"line":8,"character":0}},"newText":"\n\n"},{"range":{"start":{"line":5,"character":5},"end":{"line":6,"character":0}},"newText":"\n"},{"range":{"start":{"line":4,"character":24},"end":{"line":5,"character":4}},"newText":"\n "},{"range":{"start":{"line":3,"character":30},"end":{"line":4,"character":8}},"newText":"\n "},{"range":{"start":{"line":3,"character":28},"end":{"line":3,"character":29}},"newText":"\n "},{"range":{"start":{"line":2,"character":14},"end":{"line":3,"character":4}},"newText":"\n "},{"range":{"start":{"line":1,"character":15},"end":{"line":2,"character":4}},"newText":"\n "},{"range":{"start":{"line":1,"character":13},"end":{"line":1,"character":14}},"newText":"\n"},{"range":{"start":{"line":0,"character":5},"end":{"line":1,"character":0}},"newText":"\n"}]}

User avatar
Rickard Johansson
Site Admin
Posts: 6108
Joined: 19 Jul 2006 14:29

Re: FIXED: [14.90b1] Format document is a mess

Post by Rickard Johansson »

Seems formatting the entire document works fine if you omit the PHP closing tag at the end of your document...

User avatar
pjj
Posts: 1872
Joined: 13 Oct 2009 13:48
Location: Kraków, Poland

Re: FIXED: [14.90b1] Format document is a mess

Post by pjj »

Interesting. It is a good practice (and even a standard) to omit PHP closing tag at the end of a file with PHP code!
Alium tibi quaere fratrem; hic, quem tuum putas, meus est. Titus Flāvius Caesar Vespasiānus Augustus

Post Reply