I am trying to write the simplest ever snippet for Kdevelop (5.1).
It should simply take my selected text and embrace it with #if 0 ... #endif.
#if 0
my current selection
#endif
Snippet code is:
#if 0 
${view.selection()}
#endif
And all I receive back is the error:
#if 0 
ReferenceError: Can't find variable: Range
#endif
All I know is that this Kate / Kdevelop snippets use Javascript, so I think this simple view.selection() oughta work, but it doesn't.
Is there a way to accomplish what I want?
How to fix this Range error?
Thanks.
EDIT:
I added a function selection_or_nothing() to the functions tab, a require ("range.js") before it and changed my snippet to call it.
require ("range.js");
function selection_or_nothing() 
{
    if ( view.hasSelection() )
        return view.selection();
    return "";
}
Snippet:
#if 0
${selection_or_nothing()}
#endif  // ${comment}
This is what I have now:
#if 0
Range(Cursor(200,0), Cursor(201,0))
#endif
				
                        
This works here:
I think you need to use view.selectedText() instead of view.selection(), or this pre-defined function.