#613 Map snippet completion key per snippet


Having a global key for snippet completion sometimes undesirable, for instance in Pascal with space as snippet completion:

if=if %cursor% then

it works OK with "if" but not quite with "begin", this is due to normally people press enter instead of space after "begin". To maintain backward compatibility, the current snippet format could be maintained and still uses the global key. However, if another "=" symbol occurs then its content up to the next "=" is considered as overriden shortcut for snippet completion. For instance:

if=space=if %cursor% then

it could be difficult to parse I think, so you might want to use other symbol or switch the key as the last instead of the middle part.


  • Lex Trotman

    Lex Trotman - 2012-07-30

    This means that *every* keystroke needs to check the preceding characters to see if they are a snippet and then look up if the completion matches the current keystroke rather than knowing which keystroke wants to complete a snippet and only when searching if the preceding characters match one of the snippets.

    Thats a big difference in the processing per character.

  • Mario Ray M.

    Mario Ray M. - 2012-07-30

    Exactly. However, it's not that big actually. I haven't seen how Geany handles this snippet completion internally (read: the code). If it's using Scintilla's feature, it shouldn't be too hard. A simple 2-level hashmap should do it fast without the user noticing much lag. I've implemented this in SciTE using its Lua scripting extension and indeed the difference is negligible.

    Anyway, the snippet file is read once per change right? Not everytime a completion is triggered? Because if that's so, it would be a problem...


Log in to post a comment.