Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong formatting with comments. #122

Closed
Shu-Ji opened this issue Dec 29, 2023 · 4 comments
Closed

Wrong formatting with comments. #122

Shu-Ji opened this issue Dec 29, 2023 · 4 comments

Comments

@Shu-Ji
Copy link

Shu-Ji commented Dec 29, 2023

-- comment 111
SELECT * from tb1;
-- comment 222
SELECT * from tb2;

Formatting Request:

{
    "jsonrpc": "2.0",
    "method": "textDocument/formatting",
    "params": {
        "textDocument": {
            "uri": "file:///workspace/mysql.sql"
        },
        "options": {
            "tabSize": 4,
            "insertSpaces": true
        }
    },
    "id": 1703824210
}

Original code:
image

lsp-server result:

{
    "id": 1703824210,
    "result": [
        {
            "range": {
                "start": {
                    "line": 0,
                    "character": 14
                },
                "end": {
                    "line": 3,
                    "character": 18
                }
            },
            "newText": "SELECT\n    *\nFROM\n    tb1;SELECT\n        *\n    FROM\n        tb2;"
        }
    ],
    "jsonrpc": "2.0"
}

Formatted code:
image

Problem:

  1. Comments were removed.
  2. The second SELECT is on wrong line.
@mattn
Copy link
Member

mattn commented Dec 29, 2023

@lighttiger2505 from my understanding, sqls does not support multiple SQL statements. right?

@Shu-Ji
Copy link
Author

Shu-Ji commented Dec 29, 2023

@lighttiger2505 from my understanding, sqls does not support multiple SQL statements. right?

Even one statement will not work(Comment will be removed after formatting):

-- comment 111
SELECT * from tb1;

@mattn
Copy link
Member

mattn commented Dec 29, 2023

addressed in #123

@mattn
Copy link
Member

mattn commented Dec 30, 2023

fixed in #123

@mattn mattn closed this as completed Dec 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants