Skip to content
Browse files

Change folding commands so that they do not require a ParserFoldingSt…

…rategy.

This fixes "toggle all foldings" for .xml files.
  • Loading branch information...
1 parent 6699d0b commit 65394ce3e041ededda9491117fb91c0816c7b858 @dgrunwald dgrunwald committed
Showing with 11 additions and 11 deletions.
  1. +11 −11 src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Commands/FoldingCommands.cs
View
22 src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Commands/FoldingCommands.cs
@@ -16,14 +16,14 @@ public override void Run()
{
ITextEditorProvider provider = WorkbenchSingleton.Workbench.ActiveViewContent as ITextEditorProvider;
ITextEditor editor = provider.TextEditor;
- ParserFoldingStrategy strategy = editor.GetService(typeof(ParserFoldingStrategy)) as ParserFoldingStrategy;
+ FoldingManager foldingManager = editor.GetService(typeof(FoldingManager)) as FoldingManager;
- if (strategy != null) {
+ if (foldingManager != null) {
// look for folding on this line:
- FoldingSection folding = strategy.FoldingManager.GetNextFolding(editor.Document.PositionToOffset(editor.Caret.Line, 1));
+ FoldingSection folding = foldingManager.GetNextFolding(editor.Document.PositionToOffset(editor.Caret.Line, 1));
if (folding == null || editor.Document.GetLineForOffset(folding.StartOffset).LineNumber != editor.Caret.Line) {
// no folding found on current line: find innermost folding containing the caret
- folding = strategy.FoldingManager.GetFoldingsContaining(editor.Caret.Offset).LastOrDefault();
+ folding = foldingManager.GetFoldingsContaining(editor.Caret.Offset).LastOrDefault();
}
if (folding != null) {
folding.IsFolded = !folding.IsFolded;
@@ -38,17 +38,17 @@ public override void Run()
{
ITextEditorProvider provider = WorkbenchSingleton.Workbench.ActiveViewContent as ITextEditorProvider;
ITextEditor editor = provider.TextEditor;
- ParserFoldingStrategy strategy = editor.GetService(typeof(ParserFoldingStrategy)) as ParserFoldingStrategy;
+ FoldingManager foldingManager = editor.GetService(typeof(FoldingManager)) as FoldingManager;
- if (strategy != null) {
+ if (foldingManager != null) {
bool doFold = true;
- foreach (FoldingSection fm in strategy.FoldingManager.AllFoldings) {
+ foreach (FoldingSection fm in foldingManager.AllFoldings) {
if (fm.IsFolded) {
doFold = false;
break;
}
}
- foreach (FoldingSection fm in strategy.FoldingManager.AllFoldings) {
+ foreach (FoldingSection fm in foldingManager.AllFoldings) {
fm.IsFolded = doFold;
}
}
@@ -61,10 +61,10 @@ public override void Run()
{
ITextEditorProvider provider = WorkbenchSingleton.Workbench.ActiveViewContent as ITextEditorProvider;
ITextEditor editor = provider.TextEditor;
- ParserFoldingStrategy strategy = editor.GetService(typeof(ParserFoldingStrategy)) as ParserFoldingStrategy;
+ FoldingManager foldingManager = editor.GetService(typeof(FoldingManager)) as FoldingManager;
- if (strategy != null) {
- foreach (FoldingSection fm in strategy.FoldingManager.AllFoldings) {
+ if (foldingManager != null) {
+ foreach (FoldingSection fm in foldingManager.AllFoldings) {
fm.IsFolded = ParserFoldingStrategy.IsDefinition(fm);
}
}

0 comments on commit 65394ce

Please sign in to comment.
Something went wrong with that request. Please try again.