Skip to content

Commit

Permalink
Improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Matteo Prosperi committed Nov 17, 2023
1 parent e7f8bba commit 736c73d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ namespace FeatureGallery;
internal class EditorMarginTest : TestData
{
#if INPROC
private const string BackgroundColor = "blue";
public const string FileExtension = "mywords";
#else
private const string BackgroundColor = "pink";
public const string FileExtension = "words";
#endif

public EditorMarginTest(VisualStudioExtensibility extensibility)
Expand All @@ -31,21 +31,21 @@ public EditorMarginTest(VisualStudioExtensibility extensibility)
}

[VisualStudioContribution]
public static DocumentTypeConfiguration WordsDocumentType => new("words")
public static DocumentTypeConfiguration WordsDocumentType => new(FileExtension)
{
FileExtensions = new[] { ".words" },
FileExtensions = new[] { "." + FileExtension },
BaseDocumentType = DocumentType.KnownValues.Text,
};

[DataMember]
public override string ButtonText => "Editor margin";

[DataMember]
public override string Description => $"This command opens a text document with a custom {BackgroundColor} editor margin counting the words in the document. A prompt will ask to close the file.";
public override string Description => $"This command opens a text document with a custom editor margin counting the words in the document. A prompt will ask to close the file.";

protected override async Task RunAsync(IClientContext clientContext, CancellationToken cancellationToken)
{
var filePath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName() + ".words");
var filePath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName() + "." + FileExtension);
bool keepFile = false;

using var file = new StreamWriter(File.Create(filePath));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<DataTemplate xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vs="http://schemas.microsoft.com/visualstudio/extensibility/2022/xaml">
<DockPanel Background="{Binding Background}" TextBlock.FontSize="11" Height="16">
<DockPanel Background="LightSkyBlue" TextBlock.FontSize="11" Height="16">
<StackPanel Orientation="Horizontal">
<TextBlock Padding="2, 0, 2, 0">Words: </TextBlock>
<TextBlock x:Name="WordCountText" Text="{Binding WordCount}"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,4 @@ public int WordCount
get => this.wordCount;
set => this.SetProperty(ref this.wordCount, value);
}

[DataMember]
public string Background
#if INPROC
=> "LightSkyBlue";
#else
=> "LightPink";
#endif
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public LanguageServerTest(VisualStudioExtensibility extensibility)

[VisualStudioContribution]
#pragma warning disable VSEXTAPI0001 // This API is marked as Preview.
public static DocumentTypeConfiguration TodosDocumentType => new("todo")
public static DocumentTypeConfiguration TodosDocumentType => new(FileExtension)
{
FileExtensions = new[] { "." + FileExtension },
BaseDocumentType = LanguageServerProvider.LanguageServerBaseDocumentType,
Expand Down

0 comments on commit 736c73d

Please sign in to comment.