Author Topic: [Code snippets plugin] Suggestion  (Read 3052 times)

Offline wxLearner

  • Multiple posting newcomer
  • *
  • Posts: 71
[Code snippets plugin] Suggestion
« on: March 09, 2007, 11:05:38 am »
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: [Select]
snippet.Replace(wxT("\n"), wxT('\n') + editor->GetLineIndentString(ctrl->GetCurrentLine()));It would be nice, if that could be added.

Thank you.

Offline jamieo

  • Multiple posting newcomer
  • *
  • Posts: 26
Re: [Code snippets plugin] Suggestion
« Reply #1 on: March 21, 2007, 10:29:03 pm »
Yes, that would be a nice change (thanks wxLearner) - I tried this plugin but dismissed it because of this very issue.

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2150
Re: [Code snippets plugin] Suggestion
« Reply #2 on: March 22, 2007, 12:32:52 am »
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.

Offline jamieo

  • Multiple posting newcomer
  • *
  • Posts: 26
Re: [Code snippets plugin] Suggestion
« Reply #3 on: March 22, 2007, 01:21:15 am »
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: [Select]
switch ()
{
case :
break;

default:
break;
}

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: [Select]
switch ()
{
case :
break;

default:
break;
}


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: [Select]
switch ()
{
case :
break;

default:
break;
}
« Last Edit: March 22, 2007, 01:33:25 am by jamieo »

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2150
Re: [Code snippets plugin] Suggestion
« Reply #4 on: March 22, 2007, 02:45:05 am »
Ah.. I get it now

thanks

Edit: Fixed svn 3737