diff --git a/src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlLanguageBinding.cs b/src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlLanguageBinding.cs index 852d5fd1ae..f7cc769f14 100644 --- a/src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlLanguageBinding.cs +++ b/src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlLanguageBinding.cs @@ -2,6 +2,7 @@ // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using System; +using ICSharpCode.AvalonEdit.Highlighting; using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop.Editor; @@ -20,9 +21,10 @@ namespace ICSharpCode.XmlEditor { // HACK: disable SharpDevelop's built-in folding codeEditorView = editor.GetService(typeof(AvalonEdit.TextEditor)) as AvalonEdit.AddIn.CodeEditorView; - if (codeEditorView != null) - codeEditorView.DisableParseInformationFolding = true; - + DisableParseInformationFolding(); + + UpdateHighlightingIfNotXml(); + foldingManager = new XmlFoldingManager(editor); foldingManager.UpdateFolds(); foldingManager.Start(); @@ -30,15 +32,54 @@ namespace ICSharpCode.XmlEditor base.Attach(editor); } + void UpdateHighlightingIfNotXml() + { + if (codeEditorView != null) { + if (!IsUsingXmlHighlighting()) { + ChangeHighlightingToXml(); + } + } + } + + bool IsUsingXmlHighlighting() + { + IHighlightingDefinition highlighting = codeEditorView.SyntaxHighlighting; + if (highlighting != null) { + return highlighting.Name == "XML"; + } + return false; + } + + void ChangeHighlightingToXml() + { + codeEditorView.SyntaxHighlighting = HighlightingManager.Instance.GetDefinition("XML"); + } + public override void Detach() { foldingManager.Stop(); foldingManager.Dispose(); - if (codeEditorView != null) - codeEditorView.DisableParseInformationFolding = false; + EnableParseInformationFolding(); base.Detach(); } + + void DisableParseInformationFolding() + { + DisableParseInformationFolding(true); + } + + void DisableParseInformationFolding(bool disable) + { + if (codeEditorView != null) { + codeEditorView.DisableParseInformationFolding = disable; + } + } + + void EnableParseInformationFolding() + { + DisableParseInformationFolding(false); + } } } diff --git a/src/AddIns/DisplayBindings/XmlEditor/XmlEditor.sln b/src/AddIns/DisplayBindings/XmlEditor/XmlEditor.sln index 3fa292e4e4..49f718f1d1 100644 --- a/src/AddIns/DisplayBindings/XmlEditor/XmlEditor.sln +++ b/src/AddIns/DisplayBindings/XmlEditor/XmlEditor.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 -# SharpDevelop 4.0.0.6374 +# SharpDevelop 4.1.0.7289-alpha Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XmlEditor", "Project\XmlEditor.csproj", "{DCA2703D-250A-463E-A68A-07ED105AE6BD}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XmlEditor.Tests", "Test\XmlEditor.Tests.csproj", "{FC0FE702-A87D-4D70-A9B6-1ECCD611125F}" @@ -22,6 +22,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NRefactory", "..\..\..\Libr EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop.Tests", "..\..\..\Main\Base\Test\ICSharpCode.SharpDevelop.Tests.csproj", "{4980B743-B32F-4aba-AABD-45E2CAD3568D}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AvalonEdit.AddIn", "..\AvalonEdit.AddIn\AvalonEdit.AddIn.csproj", "{0162E499-42D0-409B-AA25-EED21F75336B}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -72,5 +74,9 @@ Global {4980B743-B32F-4ABA-AABD-45E2CAD3568D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {4980B743-B32F-4ABA-AABD-45E2CAD3568D}.Release|Any CPU.Build.0 = Release|Any CPU {4980B743-B32F-4ABA-AABD-45E2CAD3568D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0162E499-42D0-409B-AA25-EED21F75336B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0162E499-42D0-409B-AA25-EED21F75336B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0162E499-42D0-409B-AA25-EED21F75336B}.Release|Any CPU.Build.0 = Release|Any CPU + {0162E499-42D0-409B-AA25-EED21F75336B}.Release|Any CPU.ActiveCfg = Release|Any CPU EndGlobalSection EndGlobal