Snippet Indentation after a Surround with

SyntaxEditor for Windows Forms Forum

Posted 8 years ago by BLANC Stéphane - Staubli Robotics Suite Product Manager, STAUBLI
Version: 4.0.0288
Avatar
Hi,

I have a bug that I'm not able to solve.
When I use the "Surround with" command, the indentation is not correct as shown in the example below :

for l_nIndex=0 to l_nLength
 do
  ...
  ...
until  // invalid indentation
endFor
I would like to call the void FormatTextRange method just after the 'surround with' but I can't find the place to insert the code (overridden method or event) to do that.

Do you have an idea to solve this ?

Thanks for your help

Stéphane

Comments (3)

Posted 8 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Stéphane,

You could probably do something like that in an SyntaxEditor.CodeSnippetDeactivated event handler.


Actipro Software Support

Posted 8 years ago by BLANC Stéphane - Staubli Robotics Suite Product Manager, STAUBLI
Avatar
I already tried this solution but the event is raised too late.
I want to update the indentation just after the "insert" of the snippet.

Stéphane
Posted 8 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Stéphane,

I was looking at the code snippets code. It looks like we do some form of auto-indent. But it's all tied to how the original snippet was indented. So if indenting was ok in the original code snippet file, it should show up the same way when the code snippet is activated, although there the entire code snippet is indented more by the current tab stop level.

I saw you sent us some screenshots. If you would like us to take a further look into this, perhaps you could supply us with the exact steps to repro it in our sample project, or supply a new simple sample project if that is easier.

Back on your question. If there are no fields to activate, the CodeSnippetDeactivated will fire right after everything is inserted. If there are fields to activate, a CodeSnippetFieldActivated event for the first field will happen right away. So you could trigger your code in that first CodeSnippetFieldActivated event.

On a side note, the text insertion happens with a type of InsertCodeSnippetTemplate, however if you modify the inserted text between that and the events being fired, all the indicators will be offset incorrectly, so that's why I didn't suggest that.

But still based on your screens it seems like perhaps there is a bug in how we indent the surrounded code. So a sample would be most helpful towards fixing that.


Actipro Software Support

The latest build of this product (v2018.1 build 0341) was released 9 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.