Developer forums (C::B DEVELOPMENT STRICTLY!) > Plugins development

[Code snippets plugin] Suggestion

(1/1)

wxLearner:
Hello,
I like the code snippets plugin and would like to suggest a small change. If you have a snippet, that consists of multiple lines, the content from the second line on isn't indented. I've looked into the code of the abbreviation feature, how to support indentation. The code snippets plugin needs one additional line of code only (in the method CodeSnippetsWindow::ApplySnippet before ctrl->AddText(snippet);):
--- Code: ---snippet.Replace(wxT("\n"), wxT('\n') + editor->GetLineIndentString(ctrl->GetCurrentLine()));
--- End code ---
It would be nice, if that could be added.

Thank you.

jamieo:
Yes, that would be a nice change (thanks wxLearner) - I tried this plugin but dismissed it because of this very issue.

Pecan:
Could you explain the problem more fully. I can't seem to get the error.



The first three lines have tabs, and the last three have spaces as indentations. They seemed to have "apply"'d properly.

Could you paste an example of the problem.

jamieo:
If you insert the same snippet after a couple of tabs the snippet won't maintain it's tab structure.  The first switch block below is correct as it has been inserted at the first column.  It is exactly the same as the original snippet template (no indentation applied).


--- Code: ---switch ()
{
case :
break;

default:
break;
}
--- End code ---

The next snippet is inserted after two tabs but the tab structure is incorrect - only the first line is indented.  The snippet has just been pasted with the same tabs it had in the original template (no indentation applied).  This is awkward as most code has some level of indentation.


--- Code: --- switch ()
{
case :
break;

default:
break;
}


--- End code ---

With the change wxLearner has suggested the existing indentation level is automatically applied to the whole snippet so the block will match it's surrounding code.


--- Code: --- switch ()
{
case :
break;

default:
break;
}

--- End code ---

Pecan:
Ah.. I get it now

thanks

Edit: Fixed svn 3737

Navigation

[0] Message Index

Go to full version