Bug 298793 - Simple snippet replaces more text than has been selected
Summary: Simple snippet replaces more text than has been selected
Status: RESOLVED FIXED
Alias: None
Product: kate
Classification: Unclassified
Component: plugin-snippets (show other bugs)
Version: unspecified
Platform: Ubuntu Packages Linux
: NOR normal (vote)
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-04-25 09:35 UTC by Romek
Modified: 2012-11-04 20:54 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Romek 2012-04-25 09:35:21 UTC
I have very simple snippet:

%{selection}

When I use it on more than one selected line it replaces more than have been selected.
E.g. for text like following: 
1
2
3
4
5

running above snippet on selected lines 2 and 3 will result:
1
2
3
5

It means, line 4 has been cut.

Reproducible: Always

Steps to Reproduce:
1. Make simple snippet
2. Select a text
3. Run a snippet
Actual Results:  
Removed more text than inserted.

Expected Results:  
This snippet should result in same text as before running snippet.

It works ok for one line selection.
Comment 1 Milian Wolff 2012-04-25 12:13:28 UTC
confirmed
Comment 2 lxg 2012-07-02 21:06:26 UTC
I have the same bug (in Kdevelop). I'm using the following snippet:

   Translate::t(%{selection})

and it always "eats" some or all of the trailing characters.
Comment 3 lxg 2012-07-02 21:10:49 UTC
Sorry, forgot to explicitely mention that it does *not* work with one-line selections for me.
Comment 4 Christoph Cullmann 2012-11-04 20:50:22 UTC
Git commit 860e9f13f9c73563166b01f988f7e55aee9b29c3 by Christoph Cullmann.
Committed on 04/11/2012 at 21:49.
Pushed by cullmann into branch 'master'.

some fixes for template interface usage in snippets
still %{selection} inserts one space too much, but at least doesn't eat text :/

M  +1    -1    part/snippet/katesnippetglobal.cpp
M  +5    -26   part/snippet/snippetcompletionitem.cpp
M  +2    -2    part/snippet/snippetcompletionitem.h
M  +4    -2    part/snippet/snippetcompletionmodel.cpp
M  +3    -0    part/snippet/snippetcompletionmodel.h

http://commits.kde.org/kate/860e9f13f9c73563166b01f988f7e55aee9b29c3
Comment 5 Christoph Cullmann 2012-11-04 20:54:53 UTC
Ah, I see, the "space" is wanted in the implementation, then this is fixed now.