Browse Source

Fixed SD2-808: Indenting comment when typing colon character or ( )

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/2.0@1430 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 19 years ago
parent
commit
aac539edf7
  1. 4
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/FormattingStrategy/CSharpFormattingStrategy.cs
  2. 8
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/FormattingStrategy/Indentation.cs
  3. 2
      src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/HighlightingStrategy/DefaultHighlightingStrategy.cs

4
src/AddIns/BackendBindings/CSharpBinding/Project/Src/FormattingStrategy/CSharpFormattingStrategy.cs

@ -417,8 +417,8 @@ namespace CSharpBinding.FormattingStrategy
return IndentLine(textArea, lineNr) + "#endregion".Length; return IndentLine(textArea, lineNr) + "#endregion".Length;
} }
if (lineAbove.HighlightSpanStack != null && lineAbove.HighlightSpanStack.Count > 0) { if (lineAbove.HighlightSpanStack != null && !lineAbove.HighlightSpanStack.IsEmpty) {
if (!((Span)lineAbove.HighlightSpanStack.Peek()).StopEOL) { // case for /* style comments if (!lineAbove.HighlightSpanStack.Peek().StopEOL) { // case for /* style comments
int index = lineAboveText.IndexOf("/*"); int index = lineAboveText.IndexOf("/*");
if (index > 0) { if (index > 0) {
StringBuilder indentation = new StringBuilder(GetIndentation(textArea, lineNr - 1)); StringBuilder indentation = new StringBuilder(GetIndentation(textArea, lineNr - 1));

8
src/AddIns/BackendBindings/CSharpBinding/Project/Src/FormattingStrategy/Indentation.cs

@ -321,7 +321,8 @@ namespace CSharpBinding.FormattingStrategy
// statement). // statement).
if (!oldBlock.Continuation && !oldBlock.OneLineBlock && if (!oldBlock.Continuation && !oldBlock.OneLineBlock &&
oldBlock.StartLine == block.StartLine && oldBlock.StartLine == block.StartLine &&
block.StartLine < doc.LineNumber && lastRealChar != ':') { block.StartLine < doc.LineNumber && lastRealChar != ':')
{
// use indent StringBuilder to get the indentation of the current line // use indent StringBuilder to get the indentation of the current line
indent.Length = 0; indent.Length = 0;
line = doc.Text; // get untrimmed line line = doc.Text; // get untrimmed line
@ -330,6 +331,11 @@ namespace CSharpBinding.FormattingStrategy
break; break;
indent.Append(line[i]); indent.Append(line[i]);
} }
// /* */ multiline comments have an extra space - do not count it
// for the block's indentation.
if (startInComment && indent.Length > 0 && indent[indent.Length - 1] == ' ') {
indent.Length -= 1;
}
block.InnerIndent = indent.ToString(); block.InnerIndent = indent.ToString();
} }
return; return;

2
src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/HighlightingStrategy/DefaultHighlightingStrategy.cs

@ -452,7 +452,7 @@ namespace ICSharpCode.TextEditor.Document
void UpdateSpanStateVariables() void UpdateSpanStateVariables()
{ {
inSpan = (currentSpanStack != null && !currentSpanStack.IsEmpty); inSpan = (currentSpanStack != null && !currentSpanStack.IsEmpty);
activeSpan = inSpan ? (Span)currentSpanStack.Peek() : null; activeSpan = inSpan ? currentSpanStack.Peek() : null;
activeRuleSet = GetRuleSet(activeSpan); activeRuleSet = GetRuleSet(activeSpan);
} }

Loading…
Cancel
Save