[Bug?] Surround With Live Template does not always determine the correct context

I thought I'd ask for feedback from the group before posting this as a bug. It feels like one to me, but others may like it...

In the example code below, if you place the caret within the word Hello and then do CTRL-W (Select Word at Caret) at least 3 times and then do a Surround With Live Template, IDEA considers the context to be Java String.

However, if you start by placing the caret within, say, the word println and then do CTRL-W at least 4 times (which yields the same selection as doing CTRL-W 3 times in the above case) and then do a Surround With Live Template, IDEA considers the context to be Java Code.


I expected the context to be determined from what I have selected, not simply where the caret is located.

The above example is perhaps clearer because the context is Java Code at both the ends of the selection. I guess the problem arises when there's a mix of contexts, e.g. a selection that includes a line of code followed by a comment. In the case of more than one context, maybe IDEA could instead present all applicable Live Templates?

Thoughts?

2 comments

This seems to be a bug for me. Please submit a request.

--
Valentin Kipiatkov
JetBrains, Inc
http://www.intellij.com
"Develop with pleasure!"

"Chris Bartley" <jiveadmin@jetbrains.com> wrote in message
news:6100302.1053053852165.JavaMail.jrun@is.intellij.net...

I thought I'd ask for feedback from the group before posting this as a

bug. It feels like one to me, but others may like it...
>

In the example code below, if you place the caret within the word

Hello and then do CTRL-W (Select Word at Caret) at least 3
times and then do a Surround With Live Template, IDEA considers the
context to be Java String.
>

However, if you start by placing the caret within, say, the word

println and then do CTRL-W at least 4 times (which yields the same
selection as doing CTRL-W 3 times in the above case) and then do a
Surround With Live Template, IDEA considers the context to be Java
Code.
>

 public class SurroundWithLiveTemplateTest
>    {
>    public void foo()
>       {
>       System.out.println("Hello");
>       }
>    }]]>

>

I expected the context to be determined from what I have selected, not

simply where the caret is located.
>

The above example is perhaps clearer because the context is Java Code at

both the ends of the selection. I guess the problem arises when there's a
mix of contexts, e.g. a selection that includes a line of code followed by a
comment. In the case of more than one context, maybe IDEA could instead
present all applicable Live Templates?
>

Thoughts?



0

Please sign in to leave a comment.