<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.kde.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugs.kde.org/"
          
          maintainer="sysadmin@kde.org"
>

    <bug>
          <bug_id>322118</bug_id>
          
          <creation_ts>2013-07-08 14:44:42 +0000</creation_ts>
          <short_desc>Calls to view.selectedText() in the View API from Snippets plugin fail</short_desc>
          <delta_ts>2014-09-23 20:45:13 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>2</classification_id>
          <classification>Applications</classification>
          <product>kate</product>
          <component>plugin-snippets</component>
          <version>3.10.5</version>
          <rep_platform>Arch Linux</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>NOR</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>0</everconfirmed>
          <reporter name="Graham Morrison">acquirement</reporter>
          <assigned_to name="Joseph Wenninger">jowenn</assigned_to>
          <cc>athanare</cc>
    
    <cc>mail</cc>
    
    <cc>pascal+kde</cc>
          
          <cf_commitlink></cf_commitlink>
          <cf_versionfixedin>5.1</cf_versionfixedin>
          <cf_sentryurl></cf_sentryurl>
          <votes>0</votes>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1382199</commentid>
    <comment_count>0</comment_count>
    <who name="Graham Morrison">acquirement</who>
    <bug_when>2013-07-08 14:44:42 +0000</bug_when>
    <thetext>As outlined here:
http://docs.kde.org/stable/en/applications/kate/advanced-editing-tools-scripting.html

When writing a script to accompany a Snippet, calls to functions in the View API don&apos;t appear to work. Specifically, no string is returned from view.selectedText().

Reproducible: Always

Steps to Reproduce:
1. With Snippets plugin installed, create and name a new Snippet.
2. Enter:

${fn`getSelectedText`}

as the text in the Snippet tab.
3. Enter:

function getSelectedText() {
return view.selectedText();
}

as the text in the Scripts tab.
4. Apply the changes.
5. Select some text and run the Snippet.
Actual Results:  
Nothing. Seems to return null.

Expected Results:  
The text selected in the main view should be returned.

This function used to be provided within Snippets by the ${selection} keyword, but this no longer functions either. It&apos;s important for writing Snippets that surround the selected text with HTML elements, for example.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1393447</commentid>
    <comment_count>1</comment_count>
    <who name="Pascal Niklaus">pascal+kde</who>
    <bug_when>2013-08-29 11:44:49 +0000</bug_when>
    <thetext>I can confirm this behaviour.

inserting e.g. %{date} works, but %{selection} does not work.

This behaviour is critical since one often wants to write snippets that &quot;surround&quot; an existing block of text.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1472656</commentid>
    <comment_count>2</comment_count>
    <who name="Sven Brauch">mail</who>
    <bug_when>2014-09-23 20:45:04 +0000</bug_when>
    <thetext>Fixed in 5 with changes to the snippets engine. Use ${selection()} to get the selected text.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>