Skip to content

Commit

Permalink
Change the spell checker support by:
Browse files Browse the repository at this point in the history
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
Noah Richards committed Mar 12, 2010
1 parent e7de8cc commit 9a8449c
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 2 deletions.
1 change: 0 additions & 1 deletion ContentType.cs
Expand Up @@ -10,7 +10,6 @@ static class ContentType
[Export]
[Name(Name)]
[DisplayName("Markdown")]
[BaseDefinition("plaintext")]
[BaseDefinition("HTML")]
public static ContentTypeDefinition MarkdownModeContentType = null;

Expand Down
7 changes: 7 additions & 0 deletions MarkdownMode.csproj
Expand Up @@ -88,6 +88,7 @@
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
</Compile>
<Compile Include="SpellcheckSupport\MarkdownNaturalTextTagger.cs" />
<Compile Include="ToolWindow\Guids.cs" />
<Compile Include="ToolWindow\PreviewWindowUpdateListener.cs" />
<Compile Include="ToolWindow\Package.cs" />
Expand Down Expand Up @@ -128,6 +129,12 @@
<MergeWithCTO>true</MergeWithCTO>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="Spellchecker\SpellChecker.Definitions\SpellChecker.Definitions.csproj">
<Project>{87D22AC6-424B-48DD-A5E8-DCB7CB3DDD63}</Project>
<Name>SpellChecker.Definitions</Name>
</ProjectReference>
</ItemGroup>
<PropertyGroup>
<RegisterOutputPackage>true</RegisterOutputPackage>
<RegisterWithCodebase>true</RegisterWithCodebase>
Expand Down
6 changes: 6 additions & 0 deletions MarkdownMode.sln
Expand Up @@ -3,6 +3,8 @@ Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MarkdownMode", "MarkdownMode.csproj", "{1017287A-83B1-41AB-BAC2-045AC45607C7}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SpellChecker.Definitions", "Spellchecker\SpellChecker.Definitions\SpellChecker.Definitions.csproj", "{87D22AC6-424B-48DD-A5E8-DCB7CB3DDD63}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -13,6 +15,10 @@ Global
{1017287A-83B1-41AB-BAC2-045AC45607C7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1017287A-83B1-41AB-BAC2-045AC45607C7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1017287A-83B1-41AB-BAC2-045AC45607C7}.Release|Any CPU.Build.0 = Release|Any CPU
{87D22AC6-424B-48DD-A5E8-DCB7CB3DDD63}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{87D22AC6-424B-48DD-A5E8-DCB7CB3DDD63}.Debug|Any CPU.Build.0 = Debug|Any CPU
{87D22AC6-424B-48DD-A5E8-DCB7CB3DDD63}.Release|Any CPU.ActiveCfg = Release|Any CPU
{87D22AC6-424B-48DD-A5E8-DCB7CB3DDD63}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
40 changes: 40 additions & 0 deletions SpellcheckSupport/MarkdownNaturalTextTagger.cs
@@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SpellChecker.Definitions;
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Text.Tagging;
using System.ComponentModel.Composition;
using Microsoft.VisualStudio.Utilities;

namespace MarkdownMode.SpellcheckSupport
{
[Export(typeof(ITaggerProvider))]
[ContentType(ContentType.Name)]
[TagType(typeof(NaturalTextTag))]
class MarkdownNaturalTextTaggerProvider : ITaggerProvider
{
public ITagger<T> CreateTagger<T>(ITextBuffer buffer) where T : ITag
{
return new MarkdownNaturalTextTagger() as ITagger<T>;
}
}

class MarkdownNaturalTextTagger : ITagger<NaturalTextTag>
{
public IEnumerable<ITagSpan<NaturalTextTag>> GetTags(NormalizedSnapshotSpanCollection spans)
{
foreach (var snapshotSpan in spans)
{
yield return new TagSpan<NaturalTextTag>(snapshotSpan, new NaturalTextTag());
}
}

#pragma warning disable 67
public event EventHandler<SnapshotSpanEventArgs> TagsChanged;
#pragma warning restore 67
}

class NaturalTextTag : INaturalTextTag { }
}
2 changes: 1 addition & 1 deletion Spellchecker

0 comments on commit 9a8449c

Please sign in to comment.