Skip to content

Commit

Permalink
ignore single line comments
Browse files Browse the repository at this point in the history
  • Loading branch information
darrenkopp committed Nov 2, 2013
1 parent 4464d31 commit 4dc951f
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions SassyStudio.2012/Editor/FormatDocumentHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ protected override bool Execute(VSCommand command, uint options, IntPtr pvaIn, I
foreach (var line in TextView.TextBuffer.CurrentSnapshot.Lines)
{
var text = line.GetText();
if (IsSingleLineComment(text))
continue;

if (spaces > 0)
{
int offset;
Expand Down Expand Up @@ -62,6 +65,18 @@ protected override bool Execute(VSCommand command, uint options, IntPtr pvaIn, I
return true;
}

private bool IsSingleLineComment(string text)
{
for (int i = 0; i < text.Length - 1; i++)
{
char c = text[i];
if (!char.IsWhiteSpace(c))
return c == '/' && text[i + 1] == '/';
}

return false;
}

int IndexOfFirstNonWhitespaceCharacter(string text, out int offset)
{
offset = 0;
Expand Down

0 comments on commit 4dc951f

Please sign in to comment.