Skip to content
This repository
Browse code

Change the spell checker support by:

1. Including the spell checker definition assembly in the vsix
1. Creating a custom natural text tag for markdown files
1. No longer having the "markdown" content type inherit from "plaintext"
  • Loading branch information...
commit 9a8449c7d0e9282cf21bc2f88af14dd1fdb95986 1 parent e7de8cc
Noah Richards authored
1  ContentType.cs
@@ -10,7 +10,6 @@ static class ContentType
10 10 [Export]
11 11 [Name(Name)]
12 12 [DisplayName("Markdown")]
13   - [BaseDefinition("plaintext")]
14 13 [BaseDefinition("HTML")]
15 14 public static ContentTypeDefinition MarkdownModeContentType = null;
16 15
7 MarkdownMode.csproj
@@ -88,6 +88,7 @@
88 88 <AutoGen>True</AutoGen>
89 89 <DesignTime>True</DesignTime>
90 90 </Compile>
  91 + <Compile Include="SpellcheckSupport\MarkdownNaturalTextTagger.cs" />
91 92 <Compile Include="ToolWindow\Guids.cs" />
92 93 <Compile Include="ToolWindow\PreviewWindowUpdateListener.cs" />
93 94 <Compile Include="ToolWindow\Package.cs" />
@@ -128,6 +129,12 @@
128 129 <MergeWithCTO>true</MergeWithCTO>
129 130 </EmbeddedResource>
130 131 </ItemGroup>
  132 + <ItemGroup>
  133 + <ProjectReference Include="Spellchecker\SpellChecker.Definitions\SpellChecker.Definitions.csproj">
  134 + <Project>{87D22AC6-424B-48DD-A5E8-DCB7CB3DDD63}</Project>
  135 + <Name>SpellChecker.Definitions</Name>
  136 + </ProjectReference>
  137 + </ItemGroup>
131 138 <PropertyGroup>
132 139 <RegisterOutputPackage>true</RegisterOutputPackage>
133 140 <RegisterWithCodebase>true</RegisterWithCodebase>
6 MarkdownMode.sln
@@ -3,6 +3,8 @@ Microsoft Visual Studio Solution File, Format Version 11.00
3 3 # Visual Studio 2010
4 4 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MarkdownMode", "MarkdownMode.csproj", "{1017287A-83B1-41AB-BAC2-045AC45607C7}"
5 5 EndProject
  6 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SpellChecker.Definitions", "Spellchecker\SpellChecker.Definitions\SpellChecker.Definitions.csproj", "{87D22AC6-424B-48DD-A5E8-DCB7CB3DDD63}"
  7 +EndProject
6 8 Global
7 9 GlobalSection(SolutionConfigurationPlatforms) = preSolution
8 10 Debug|Any CPU = Debug|Any CPU
@@ -13,6 +15,10 @@ Global
13 15 {1017287A-83B1-41AB-BAC2-045AC45607C7}.Debug|Any CPU.Build.0 = Debug|Any CPU
14 16 {1017287A-83B1-41AB-BAC2-045AC45607C7}.Release|Any CPU.ActiveCfg = Release|Any CPU
15 17 {1017287A-83B1-41AB-BAC2-045AC45607C7}.Release|Any CPU.Build.0 = Release|Any CPU
  18 + {87D22AC6-424B-48DD-A5E8-DCB7CB3DDD63}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
  19 + {87D22AC6-424B-48DD-A5E8-DCB7CB3DDD63}.Debug|Any CPU.Build.0 = Debug|Any CPU
  20 + {87D22AC6-424B-48DD-A5E8-DCB7CB3DDD63}.Release|Any CPU.ActiveCfg = Release|Any CPU
  21 + {87D22AC6-424B-48DD-A5E8-DCB7CB3DDD63}.Release|Any CPU.Build.0 = Release|Any CPU
16 22 EndGlobalSection
17 23 GlobalSection(SolutionProperties) = preSolution
18 24 HideSolutionNode = FALSE
40 SpellcheckSupport/MarkdownNaturalTextTagger.cs
... ... @@ -0,0 +1,40 @@
  1 +using System;
  2 +using System.Collections.Generic;
  3 +using System.Linq;
  4 +using System.Text;
  5 +using SpellChecker.Definitions;
  6 +using Microsoft.VisualStudio.Text;
  7 +using Microsoft.VisualStudio.Text.Tagging;
  8 +using System.ComponentModel.Composition;
  9 +using Microsoft.VisualStudio.Utilities;
  10 +
  11 +namespace MarkdownMode.SpellcheckSupport
  12 +{
  13 + [Export(typeof(ITaggerProvider))]
  14 + [ContentType(ContentType.Name)]
  15 + [TagType(typeof(NaturalTextTag))]
  16 + class MarkdownNaturalTextTaggerProvider : ITaggerProvider
  17 + {
  18 + public ITagger<T> CreateTagger<T>(ITextBuffer buffer) where T : ITag
  19 + {
  20 + return new MarkdownNaturalTextTagger() as ITagger<T>;
  21 + }
  22 + }
  23 +
  24 + class MarkdownNaturalTextTagger : ITagger<NaturalTextTag>
  25 + {
  26 + public IEnumerable<ITagSpan<NaturalTextTag>> GetTags(NormalizedSnapshotSpanCollection spans)
  27 + {
  28 + foreach (var snapshotSpan in spans)
  29 + {
  30 + yield return new TagSpan<NaturalTextTag>(snapshotSpan, new NaturalTextTag());
  31 + }
  32 + }
  33 +
  34 +#pragma warning disable 67
  35 + public event EventHandler<SnapshotSpanEventArgs> TagsChanged;
  36 +#pragma warning restore 67
  37 + }
  38 +
  39 + class NaturalTextTag : INaturalTextTag { }
  40 +}
2  Spellchecker
... ... @@ -1 +1 @@
1   -Subproject commit 6c691a5617ef9e1a5955018dee285de6c06b3ee8
  1 +Subproject commit 608154235e3221613c540e5c5368b0d37f5dba73

0 comments on commit 9a8449c

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