Expanding ctx in file header overwrites text

Using Resharper C# 4.1.933.3 Evaluation

I have defined a fileheader containing, among other things:

<copyright file="ctx" company="mycompany">
(c) 2009 mycompany.
</copyright>


Codecleanup replaces the fileheader as expected, but it does not expand ctx to the filename. I can easily expand the filename though by selecting the word ctx and pressing tab. Unfortunately this will replace not only the ctx with the filename but also 3 more characters after the ctx, so the header looks like:

<copyright file="myfile.csompany="mycompany">
(c) 2009 mycompany.
</copyright>



Would be nice if
a) the ctx could be expanded automatically during cleanup
b) the manual expansion would not overwrite unrelated characters



3 comments
Comment actions Permalink

And... ahem..., when you select ctx from back to front (instead of front to back or Ctrl+Doubleclick), pressing tab does... replace ctx with a tab.

0
Comment actions Permalink

Hello,

LiveTemplates would not usually work on selection (and I assume ctx is a
Live Template in your case). They'd work like code completion, meaning they're
triggered on the word before the caret position. If you place caret after
ctx, the LiveTemplate is expanded on TAB. If you place the caret before ctx,
there's no LiveTemplate shortcut to the left of the caret, and whatever is
the default behavior for TAB takes place.

The three character issue could possibly be attributed to the completion
behavior, which, when applied with Enter, just inserts the result (in LiveTemplates
case, replaces the shortcut), and on TAB it replaces the non-whitespace characters
following the caret with the completion result. Doing CtrlEL for "Insert
LiveTemplate" and committing it with Enter instead of TAB will probably do
the thing. Otherwise, it could be a bug.

But, in the first place -- are you expecting the CodeCleanup to expand the
LiveTemplates in the template text automatically? Possibly I'm not quite
catching your scenario in this case.


Serge Baltic
JetBrains, Inc — http://www.jetbrains.com
“Develop with pleasure!”


0
Comment actions Permalink

As far as I can see, ctx is predefined. Actually I cant tell whats a live template as I didnt delve deep enough into R# yet. For me its a macro that I would expect to expand automatcially when inserted (however), just like Visual Assist.

Placing the caret right of the "word" wont make anything happen, pressing tab will just insert a tab but not expand it, the only way I have found to expand it, is selecting it and pressing tab (with the described bug). R# does not recognize the "word" when its not typed. Ctrl+E, L also does work, but then again it doesnt need the ctx in place anymore.

you wrote:

... and on TAB it replaces the non-whitespace characters
following the caret with the completion result...

This behaviour is already buggy, it must respect punctuation chars and special characters used in the current programming language, and not simply replace anything not "whitespace". Yet again, the bug goes further than this: my template contains  ... "ctx" company="" ..., so according to what you say it should stop overwriting at the space, but it overwrites the quotemark, the space and the following 'c' char.

Its not that I expect Code Cleanup to expand anything, but I expect to be able to parameterize the file header that R# will insert with variables from the environment. Otherwise the File Header feature is quite limited in usability.

And the selection issue (left to right, right to left, doubleclick, etc) is solveable, VisualAssist suffered from exactly the same problem some versions ago, after enough complaints they got their stuff right.

0

Please sign in to leave a comment.