Options

Snippets

unionguyunionguy Posts: 13
edited March 20, 2007 9:24AM in SQL Prompt Previous Versions
I'd like to say thanks for the quick answers to all of my questions.

I have a couple questions about snippets.

First why is "$CURSOR$" case sensitive? Just a questions its not a big deal once I found out why "$cursor$" didn't work.

Second I know you built SQL Prompt 3 from the ground up but didn't the following snippet work in the old version? And are there any plans to add it back? I know that for most things its not the useful but it is for the following example it is really useful.

"sp_who2+^{LEFT}{F5}"

Third why can't I paste into the Snippet Code textbox? Again just a question because I'm a programmer and I'm lazy and love to copy and paste.

Thanks Again.

Comments

  • Options
    Bart ReadBart Read Posts: 997 Silver 1
    Hi there,

    unionguy wrote:
    I'd like to say thanks for the quick answers to all of my questions.

    No problem. We like to try to keep everyone happy.
    unionguy wrote:
    First why is "$CURSOR$" case sensitive? Just a questions its not a big deal once I found out why "$cursor$" didn't work.

    I didn't even realise it was. That's definitely a bug. SQL isn't generally case-sensitive so requiring these placeholders to be case-sensitive is very counter-intuitive.
    unionguy wrote:
    Second I know you built SQL Prompt 3 from the ground up but didn't the following snippet work in the old version? And are there any plans to add it back? I know that for most things its not the useful but it is for the following example it is really useful.

    "sp_who2+^{LEFT}{F5}"

    This is a result of the way SQL Prompt 3 works versus the way SQL Prompt 2 works. The latter uses the SendKeys API to send keystrokes to whatever editor you're using. This allows you to implement this cool macro-like functionality by sending control keystrokes at very little extra cost. It does have a downside though in that it's slow and sometimes quite unreliable, and it can interfere with other applications (notably there have been problems with SQL Prompt 2 and Office 2007).

    SQL Prompt 3 on the other hand directly integrates as a plugin for SQL Server Management Studio (and for 3.1, which will be out later this week all being well, Management Studio Express) and Query Analyzer. These editors don't give us keystrokes: they tell us what edits have been made, and we tell them what edits we want them to make when auto-completion is used. So we're not dealing with keystrokes any more at all. Now this is faster, more reliable, and doesn't interfere with any other applications, but does mean that if we want to implement the "macro-style" snippets of SQL Prompt 2 then we have to do an awful lot more work because some things we have to send as edits, then we have to send the control keystrokes as commands (and we can't always get at the keystroke to command mappings in the editors), wait for the command(s) to complete, send some more edits etc.

    So that's part of the reason. The other reason is that we also wanted to put ourselves on the road to be able to implement a more dynamic live-template type of functionality where you could have user defined $whatever$ placeholders where you could insert text into the editor that would be inserted where $whatever$ appeared. We could also consider populating these placeholders with default values. Not a straightforward piece of functionality to get right, particularly in Query Analyzer, but very useful. Again, I don't know when this is likely to appear at this point since there are other things we need to do (like cross-database support) that have a higher priority.

    The conclusion is that we are going to improve snippets as time goes on but there's no set roadmap for doing this, and I can't guarantee when, if ever, the macro-type functionality will reappear.

    What I would say is that most of the control keystroke examples I've seen from version 2 select whatever has just been entered and then execute it, so we could consider just adding a checkbox labelled "Execute snippet after insertion" which would be relatively easy to implement. What do you think about that?
    unionguy wrote:
    Third why can't I paste into the Snippet Code textbox? Again just a question because I'm a programmer and I'm lazy and love to copy and paste.

    No, it's a fair point and that is also a bug. I think it's on the list to be fixed in the next release after 3.1.

    Sorry I can't be more helpful right now, but thanks again for posting. These bug reports and suggestions are very useful to us.


    Cheers,
    Bart
    Bart Read
    Principal Consultant
    bartread.com Ltd
Sign In or Register to comment.