Vscode-mssql: Tab characters in body strings break code snippets

Created on 12 May 2017  Â·  3Comments  Â·  Source: microsoft/vscode-mssql

User code snippets I had set up on a previous version of the mssql extension that contained tab characters in the body strings no longer work, and when viewing the sql.json file for the snippets, I get a red squiggly error indicator on the first body string that contains a tab character. Removing the tab from that string will cause the red squiggly to show up on the next body string with a tab.

  • MSSQL Extension Version: 1.0.0
  • VSCode Version: 1.12.1
  • OS Version: Windows 7 Enterprise

Steps to Reproduce:

  1. Open the sql.json file for SQL user snippets.

  2. Add the following, using tab characters for the indentation within the strings:

"Query information schema": {
    "prefix": "INFO",
    "body": [
        "SELECT",
        "   *",
        "FROM",
        "   INFORMATION_SCHEMA.COLUMNS",
        "", 
        "   INNER JOIN INFORMATION_SCHEMA.TABLES",
        "   ON INFORMATION_SCHEMA.COLUMNS.TABLE_NAME = INFORMATION_SCHEMA.TABLES.TABLE_NAME",
        "   AND INFORMATION_SCHEMA.TABLES.TABLE_TYPE <> 'VIEW'",
        "WHERE",
        "   INFORMATION_SCHEMA.COLUMNS.COLUMN_NAME = '$0'",
        "   --INFORMATION_SCHEMA.COLUMNS.TABLE_NAME = ''",
        ";"
    ],
    "description": "Query on information schema for table/column names."
}
  1. Save changes and attempt to use the snippet.

Most helpful comment

@kkwillmert I believe this is an issue in the VSCode snippet support. Taking a quick search over their issues, it appears that you should use \t instead of the tab character to have this handled correctly. This will also ensure users tabs vs. spaces preferences are respected. I'd like to close this as external if you have no objections?

All 3 comments

@kkwillmert I believe this is an issue in the VSCode snippet support. Taking a quick search over their issues, it appears that you should use \t instead of the tab character to have this handled correctly. This will also ensure users tabs vs. spaces preferences are respected. I'd like to close this as external if you have no objections?

No objections at all, and thanks for researching and passing along this
info! I had assumed it was an mssql issue since I encountered it
immediately after I updated mssql, but a few days after I last updated
VSCode. Probably I just hadn't used that particular snippet since
installing the VSCode update.

For the record, I love the mssql extension, it has entirely replaced my use
of SSMS for my day-to-day quick queries :-)

Thanks again!
-Kris

On Tue, May 16, 2017 at 7:24 PM, Kevin Cunnane notifications@github.com
wrote:

@kkwillmert https://github.com/kkwillmert I believe this is an issue in
the VSCode snippet support. Taking a quick search over their issues, it
appears that you should use t instead of the tab character to have this
handled correctly. This will also ensure users tabs vs. spaces preferences
are respected. I'd like to close this as external if you have no objections?

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/Microsoft/vscode-mssql/issues/874#issuecomment-301942522,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AZfA19j4Z0lG5yQnH8e29IUaP1obT8g6ks5r6jBBgaJpZM4NZQMv
.

Glad you're a happy user! Closing this out.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

BenWildeman picture BenWildeman  Â·  7Comments

haydnlj picture haydnlj  Â·  7Comments

casraysa picture casraysa  Â·  7Comments

leonardder picture leonardder  Â·  5Comments

klukiyan picture klukiyan  Â·  3Comments