Space bar does not expand snippet with v7.0 on SQL 2008

SE15SE15 Posts: 8
edited September 7, 2015 4:10AM in SQL Prompt
With SQL Prompt v6.x, I had a problem where snippets would not expand when I pressed the space bar. I upgraded to v7 and the space bar now seems to expand snippets in SQL Server 2012 Management Studio.

However, while working on another server with SQL 2008 with SQL Prompt v6.x, I noticed snippets were not working with the space bar there, so I upgraded to v7.x there as well. But the snippets are still not expanding in SQL 2008 when I press the space bar.

I have to press tab in order to expand the snippets.

Is this an issue with SQL Prompt? Or does the space bar just not work to expand snippets in Management Studio for SQL 2008?

I have verified that Space bar is selected under Options -> Behavior -> Insertion keys on the SQL 2008 machine.

Comments

  • Hi SE15,

    The completion keys in options are only active when you have the suggestions list open (pressing Ctrl + Space will force it to open). If the cursor is at the end of the snippet name and the suggestions list is not open, tab is the only key that will expand the snippet, regardless of the insertion key options:

    JptHdp4.png

    Best regards,

    David
  • Thanks David, that does seem to be the issue I'm observing.

    A few hours after posting my question, I noticed that the space bar started working with snippets on the SQL 2008 machine. And testing again now, I notice that if I type the snippet and press the space bar quickly on that machine, the suggestion list sometimes does not open and the snippet does not expand. But other times the snippet expands fine even though the suggestion box did not open.

    So it looks like there is a bit of latency or delay on that older server that makes it more noticeable.

    Thanks!
  • Hi SE15,

    Thanks for the follow up!

    That sounds possible. How big are the scripts you're working with?

    Best regards,

    David
  • Hi David,

    I'm just doing very simple single line queries to check the contents of tables while testing my software.

    The most common snippet I use is ssf, so literally just SELECT * FROM table

    It seems hit and miss on my SQL 2008 machine. It seems that a majority of the time, the suggestion list appears with the first few characters I type on a new line, but sometimes it doesn't. My guess is that my SQL 2008 server is slow occasionally, causing SQL Prompt to be less responsive.

    Now that I understand the issue and symptoms, it isn't a big deal, and the snippets seem to work consistently on my SQL 2012 server.

    Thanks for the help.
  • Well, I thought I was seeing consistent behavior, but this morning, SQL Prompt is not automatically displaying the suggestions list or expanding snippets with the space bar.

    I'm not great at posting images on this style of forum page, but I'm going to try.

    This is what I'm now seeing on my SQL 2012 machine--which I thought was working fine. This morning it just isn't displaying the suggestion box on this particular query window.

    SQLPromptSnippet_zps0nvbeybv.jpg

    Interestingly, if the query window is completely empty and I type "ssf", the suggestion window does appear. But after I have one SELECT statement in the query window, if I then type ssf again, the suggestion window does not appear.

    So here is the first query on the window.

    SQLPromptSnippet2_zpsr830stqs.jpg

    And then any snippet after that is not triggering the suggestion window.

    SQLPromptSnippet3_zpsvaowy6w7.jpg

    I see that if I put a semi colon at the end of the first statement, or add the GO statement after the first statement, the suggestion window then starts to appear. So my assumption is that the suggestion window, and thus snippets, only works in some situations?

    But then what seems odd is that if I don't complete a select statement, the suggestion window does work. The behavior of the suggestion window seems inconsistent.

    SQLPromptSnippet4_zpsoukocryv.jpg

    Is there any way to make the suggestion window always appear regardless of how many statements are present or in progress or in different states of completeness?
  • Hi SE15,

    Apologies for the late reply, it was a bank holiday yesterday.

    So this is Prompt thinking that ssf is actually an alias after the table name, so is letting you type that in rather than giving you suggestions.

    To get around this, you can either force the suggestions list open with Ctrl + Sapce, or turn on Asign Aliases, which will complete the aliases for you so your suggestions come in as normal:

    ExMmDcL.png

    Best regards,

    David
  • Hi David,

    Thanks for the explanation about the alias ambiguity, that makes sense.

    I'm not used to using aliases on my simple one line select statements, but since SQL Prompt handles it automatically, that is probably easier than constantly pressing CTRL+Space.

    Thanks!
  • Hi SE15,

    Not a problem!

    We're looking at whether we can be a bit smarter at this, so we might be able to get the suggestions list to come up in this situation. I'll let you know how it goes!

    Best regards,

    David
  • Thanks David.

    I would definitely appreciate an option that allowed the suggestion list to automatically appear in this situation, but I also understand the potential downside, as I do regularly encounter the situation where the suggestion list replaces something I didn't want to have replaced.

    Thanks for the help and for educating me on how the features work. I now have a few options for workarounds.

    Thanks,

    Steve
  • Hi Steve,

    We've got a private build available for you which will offer you suggestions if you put in a newline - the snippet in the block below will be suggested as expected:
    SELECT * FROM dbo.TableName
    ssf...
    

    Could you try it and let me know how it goes?

    Best regards,

    David
  • Awesome, thanks! Just tried it and it works great!

    I'll continue to work with it and let you know if I find any issues.

    Thanks!

    Steve
  • Hi Steve,

    Thanks for letting me know!

    Best regards,

    David
Sign In or Register to comment.