Moving SnippetCompletionItem to language/completion

David Nolden zwabel at googlemail.com
Sun Sep 13 22:35:16 UTC 2009


Am Sonntag 13 September 2009 22:11:50 schrieb Milian Wolff:
> David Nolden, 13.09.2009:
> > Am Sonntag 13 September 2009 21:04:04 schrieb Milian Wolff:
> > > Would it be OK to move the SnippetCompletionItem + the SelectionJumper
> > > to language/completion?
> > >
> > > I'd like to reuse that code in PHP and I think others could leverage it
> > > as well. Especially the SelectionJumper should/could be used in quite a
> > > few more places.
> > >
> > > Try it out, create a snippet and put this into it:
> > >
> > > for ( int i = 0; i < $max$; ++i ) {
> > >   $//code$
> > > }
> > >
> > > When you execute it, the following text will be inserted / completed:
> > >
> > > for ( int i = 0; i < max; ++i ) {
> > >   //code
> > > }
> > >
> > > max and //code have a colored background. max is preselected, typing
> > > will replace its contents. use Alt Left/Right for navigation. Esc will
> > > close the selection jumper.
> > >
> > > I think nearly _every_ code completion item would benefit from the
> > >  selection jumper:
> > >
> > > function completion for example:
> > > ~~
> > > void someFunc(type1 arg1, typ2 arg2);
> > > // completion could e.g. lead to:
> > > someFunc($type1 arg1$, $type2 arg2$)$$
> > > ~~
> > >
> > > I'd appreciate reviews. Also I think it should be somehow made clearer
> > > that a selection jumper is running - ideas?
> >
> > Sounds very good. I have no time for review, but some more ideas:
> > - The selection-jumper could be indicated by blinking the current range,
> > similar to a cursor (Should be fairly easy using dynamic smart-range
> > attributes)
> 
> Here I have a problem with the way kate treats the range. I have a
>  SmartRange and set it also as selection and place the cursor in front of
>  it. When I now type something, it's not the range contents that gets
>  changed, but instead I type something _in front of the range_ and the
>  range contents (the selection) gets truncated. So after typing I have an
>  empty range (which still works as a jump-position)... I don't know how to
>  fix that. Will ask the Kate devels.

That's pretty easy, you just need to set some flag either on the smart-range, 
or on the smart-cursors, something like "ExpandLeft | ExpandRight", take a 
look at the headers.

> > - ALT+left and ALT+right are a bit non-standard for input controls,
> > better would be "TAB" and "shift+TAB"
> 
> Was my first approach as well.
> 
> The problem here was that even though I ate pretty much anything KeyRelated
>  in my eventfilter, kate persisted to indent the lines. I don't know why
>  that happens. I think the code that does the "tab pressed when we have a
>  selection indents the line" is doing something wrong?
> 
> So if someone comes up with a fix for that, I'd really like to see it use
>  TAB as well.
Would need some more debugging. That event-filtering stuff is a bit 
complicated, as the real editor view is an object contained by KateView, so 
when you put the filter in the KateView directly, you won't get the expected 
result (See the event-filters in 
kdevplatform/plugins/contextbrowser/browsemanager).

> > - It should stop as soon as a newline is inserted, or when TAB is pressed
> > while in the last range
> 
> Stop on newline is great. I'll implement that right away. But the latter
>  I'm not sure of... I mean when I hit TAB accidentally and want to go back,
>  I'd like to be able to hit TAB and have it "wrap" (that's the current
>  behavior).
Yeah maybe it's better not doing that.

Greetings, David




More information about the KDevelop-devel mailing list