diff options
author | Mike Krüger <mkrueger@xamarin.com> | 2011-11-23 17:48:48 +0400 |
---|---|---|
committer | Mike Krüger <mkrueger@xamarin.com> | 2011-11-23 17:48:48 +0400 |
commit | 00c7309bec9b19ce7f5a5de2252ee704cc7ffe04 (patch) | |
tree | 8be2404038f8726f1499d36b1978185331a79600 /main/src | |
parent | 7fe4910af96e8e63ad29eee0305afa86ebdd3174 (diff) | |
parent | 0bab6c562f01a3b8dc77d79450d7d50b17a5c384 (diff) |
Merge branch 'master' into newresolver
Diffstat (limited to 'main/src')
-rw-r--r-- | main/src/addins/CSharpBinding/MonoDevelop.CSharp.Formatting/CSharpIndentEngine.cs | 17 | ||||
-rw-r--r-- | main/src/addins/CSharpBinding/MonoDevelop.CSharp.Formatting/CSharpIndentEngineStack.cs | 13 |
2 files changed, 25 insertions, 5 deletions
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Formatting/CSharpIndentEngine.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Formatting/CSharpIndentEngine.cs index 8e4127e595..13a8cf2ac5 100644 --- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Formatting/CSharpIndentEngine.cs +++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Formatting/CSharpIndentEngine.cs @@ -882,6 +882,18 @@ namespace MonoDevelop.CSharp.Formatting "pragma", "line" }; + + void CheckForParentList () + { + var after = stack.PeekInside (0); + if ((after & Inside.ParenList) == Inside.ParenList && pc == '(') { + var indent = stack.PeekIndent (0); + var kw = stack.PeekKeyword (0); + var line = stack.PeekLineNr (0); + stack.Pop (); + stack.Push (after, kw, line, 0); + } + } // This is the main logic of this class... public void Push (char c) @@ -971,10 +983,13 @@ namespace MonoDevelop.CSharp.Formatting PushCloseBrace (inside); break; case '\r': + CheckForParentList (); PushNewLine (inside); lastChar = c; return; case '\n': + CheckForParentList (); + if (lastChar == '\r') { cursor++; } else { @@ -985,8 +1000,8 @@ namespace MonoDevelop.CSharp.Formatting default: break; } - after = stack.PeekInside (0); + if ((after & Inside.PreProcessor) == Inside.PreProcessor) { for (int i = 0; i < preProcessorIndents.Length; i++) { int len = preProcessorIndents[i].Length - 1; diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Formatting/CSharpIndentEngineStack.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Formatting/CSharpIndentEngineStack.cs index 2299ece776..ca1a17f97d 100644 --- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Formatting/CSharpIndentEngineStack.cs +++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Formatting/CSharpIndentEngineStack.cs @@ -71,6 +71,11 @@ namespace MonoDevelop.CSharp.Formatting public string indent; public int nSpaces; public int lineNr; + + public override string ToString () + { + return string.Format ("[Node: inside={0}, keyword={1}, indent={2}, nSpaces={3}, lineNr={4}]", inside, keyword, indent, nSpaces, lineNr); + } }; Node[] stack; @@ -149,11 +154,11 @@ namespace MonoDevelop.CSharp.Formatting sp--; } } -// if (PropertyService.Get ("OnTheFlyFormatting", false)) { + if (nSpaces - n <= 0) { indentBuilder.Append ('\t'); -// } else { -// indentBuilder.Append (' ', nSpaces - n); -// } + } else { + indentBuilder.Append (' ', nSpaces - n); + } } else if (inside == Inside.MultiLineComment) { if (size > 0) { indentBuilder.Append (stack[sp].indent); |