From 872f43a3dc02a9d0e5e4a9515d48c4de9cc72102 Mon Sep 17 00:00:00 2001 From: Mads Kristensen Date: Tue, 11 Jan 2022 07:55:40 -0800 Subject: [PATCH] Renamed folders and fixed dropdown [release] --- src/{Language => Editor}/ClassificationTypes.cs | 0 src/{Language => Editor}/DropdownBars.cs | 2 +- src/{Language => Editor}/EditorFeatures.cs | 0 .../LanguageFactory.cs} | 12 ++---------- src/{Language => Editor}/TokenTagger.cs | 0 src/MarkdownEditor2022.csproj | 10 +++++----- src/MarkdownEditor2022Package.cs | 14 +++++++------- 7 files changed, 15 insertions(+), 23 deletions(-) rename src/{Language => Editor}/ClassificationTypes.cs (100%) rename src/{Language => Editor}/DropdownBars.cs (98%) rename src/{Language => Editor}/EditorFeatures.cs (100%) rename src/{Language/MarkdownEditor.cs => Editor/LanguageFactory.cs} (88%) rename src/{Language => Editor}/TokenTagger.cs (100%) diff --git a/src/Language/ClassificationTypes.cs b/src/Editor/ClassificationTypes.cs similarity index 100% rename from src/Language/ClassificationTypes.cs rename to src/Editor/ClassificationTypes.cs diff --git a/src/Language/DropdownBars.cs b/src/Editor/DropdownBars.cs similarity index 98% rename from src/Language/DropdownBars.cs rename to src/Editor/DropdownBars.cs index 49f8f99..40d89ca 100644 --- a/src/Language/DropdownBars.cs +++ b/src/Editor/DropdownBars.cs @@ -79,7 +79,7 @@ public override bool OnSynchronizeDropdowns(LanguageService languageService, IVs DropDownMember currentDropDown = dropDownMembers .OfType() .Where(d => d.Span.iStartLine <= line) - .LastOrDefault(); + .LastOrDefault() ?? (DropDownMember)dropDownMembers[0]; selectedMember = dropDownMembers.IndexOf(currentDropDown); selectedType = 0; diff --git a/src/Language/EditorFeatures.cs b/src/Editor/EditorFeatures.cs similarity index 100% rename from src/Language/EditorFeatures.cs rename to src/Editor/EditorFeatures.cs diff --git a/src/Language/MarkdownEditor.cs b/src/Editor/LanguageFactory.cs similarity index 88% rename from src/Language/MarkdownEditor.cs rename to src/Editor/LanguageFactory.cs index c26dffe..3d3efb4 100644 --- a/src/Language/MarkdownEditor.cs +++ b/src/Editor/LanguageFactory.cs @@ -6,12 +6,11 @@ namespace MarkdownEditor2022 { [ComVisible(true)] [Guid(PackageGuids.EditorFactoryString)] - internal sealed class MarkdownEditor : LanguageBase + internal sealed class LanguageFactory : LanguageBase { private DropdownBars _dropdownBars; - private bool _disposed; - public MarkdownEditor(object site) : base(site) + public LanguageFactory(object site) : base(site) { } public override string Name => Constants.LanguageName; @@ -53,15 +52,8 @@ public override TypeAndMemberDropdownBars CreateDropDownHelper(IVsTextView textV public override void Dispose() { - if (_disposed) - { - return; - } - - _disposed = true; _dropdownBars?.Dispose(); _dropdownBars = null; - base.Dispose(); } } diff --git a/src/Language/TokenTagger.cs b/src/Editor/TokenTagger.cs similarity index 100% rename from src/Language/TokenTagger.cs rename to src/Editor/TokenTagger.cs diff --git a/src/MarkdownEditor2022.csproj b/src/MarkdownEditor2022.csproj index e895745..3c5b09d 100644 --- a/src/MarkdownEditor2022.csproj +++ b/src/MarkdownEditor2022.csproj @@ -61,11 +61,11 @@ - - - - - + + + + + diff --git a/src/MarkdownEditor2022Package.cs b/src/MarkdownEditor2022Package.cs index 2814e7f..b0f9bf9 100644 --- a/src/MarkdownEditor2022Package.cs +++ b/src/MarkdownEditor2022Package.cs @@ -16,13 +16,13 @@ namespace MarkdownEditor2022 [ProvideMenuResource("Menus.ctmenu", 1)] [Guid(PackageGuids.MarkdownEditor2022String)] - [ProvideLanguageService(typeof(MarkdownEditor), Constants.LanguageName, 0, ShowHotURLs = false, DefaultToNonHotURLs = true, EnableLineNumbers = true, EnableAsyncCompletion = true, ShowCompletion = true, ShowDropDownOptions = true)] + [ProvideLanguageService(typeof(LanguageFactory), Constants.LanguageName, 0, ShowHotURLs = false, DefaultToNonHotURLs = true, EnableLineNumbers = true, EnableAsyncCompletion = true, ShowCompletion = true, ShowDropDownOptions = true)] [ProvideLanguageEditorOptionPage(typeof(OptionsProvider.AdvancedOptions), Constants.LanguageName, "", "Advanced", null, 0)] - [ProvideLanguageExtension(typeof(MarkdownEditor), Constants.FileExtension)] + [ProvideLanguageExtension(typeof(LanguageFactory), Constants.FileExtension)] - [ProvideEditorFactory(typeof(MarkdownEditor), 0, CommonPhysicalViewAttributes = (int)__VSPHYSICALVIEWATTRIBUTES.PVA_SupportsPreview, TrustLevel = __VSEDITORTRUSTLEVEL.ETL_AlwaysTrusted)] - [ProvideEditorLogicalView(typeof(MarkdownEditor), VSConstants.LOGVIEWID.TextView_string, IsTrusted = true)] - [ProvideEditorExtension(typeof(MarkdownEditor), Constants.FileExtension, 1000)] + [ProvideEditorFactory(typeof(LanguageFactory), 0, CommonPhysicalViewAttributes = (int)__VSPHYSICALVIEWATTRIBUTES.PVA_SupportsPreview, TrustLevel = __VSEDITORTRUSTLEVEL.ETL_AlwaysTrusted)] + [ProvideEditorLogicalView(typeof(LanguageFactory), VSConstants.LOGVIEWID.TextView_string, IsTrusted = true)] + [ProvideEditorExtension(typeof(LanguageFactory), Constants.FileExtension, 1000)] [ProvideFileIcon(Constants.FileExtension, "KnownMonikers.RegistrationScript")] public sealed class MarkdownEditor2022Package : ToolkitPackage @@ -31,9 +31,9 @@ protected override async Task InitializeAsync(CancellationToken cancellationToke { await JoinableTaskFactory.SwitchToMainThreadAsync(); - MarkdownEditor language = new(this); + LanguageFactory language = new(this); RegisterEditorFactory(language); - ((IServiceContainer)this).AddService(typeof(MarkdownEditor), language, true); + ((IServiceContainer)this).AddService(typeof(LanguageFactory), language, true); SetInternetExplorerRegistryKey();