Skip to content

Commit

Permalink
Merge pull request #11 from aglasencnik/dev
Browse files Browse the repository at this point in the history
Fix paths and whether commands are enabled
  • Loading branch information
aglasencnik authored Dec 31, 2023
2 parents f458ca7 + 080ebcf commit ed71ecd
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 21 deletions.
2 changes: 1 addition & 1 deletion EmmetVS/CommandHandlers/TabKeyCommandHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public bool ExecuteCommand(TabKeyCommandArgs args, CommandExecutionContext execu
{
if (Keyboard.Modifiers == ModifierKeys.None)
{
if (!GeneralOptions.Instance.Enable || !GeneralOptions.Instance.EnableAdvanced || !GeneralOptions.Instance.EnableTabKey)
if (!GeneralOptions.Instance.Enable || !GeneralOptions.Instance.EnableTabKey)
return false;

var docView = VS.Documents.GetActiveDocumentViewAsync().GetAwaiter().GetResult();
Expand Down
2 changes: 1 addition & 1 deletion EmmetVS/Commands/ExpandAbbreviationCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ protected override async Task ExecuteAsync(OleMenuCmdEventArgs e)
{
try
{
if (!GeneralOptions.Instance.Enable || !GeneralOptions.Instance.EnableAdvanced)
if (!GeneralOptions.Instance.Enable)
return;

var docView = await VS.Documents.GetActiveDocumentViewAsync();
Expand Down
2 changes: 1 addition & 1 deletion EmmetVS/Commands/WrapWithAbbreviationCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ protected override async Task ExecuteAsync(OleMenuCmdEventArgs e)
{
try
{
if (!GeneralOptions.Instance.Enable || !GeneralOptions.Instance.EnableAdvanced)
if (!GeneralOptions.Instance.Enable)
return;

var docView = await VS.Documents.GetActiveDocumentViewAsync();
Expand Down
9 changes: 8 additions & 1 deletion EmmetVS/EmmetVS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -149,24 +149,31 @@
</Content>
<Content Include="Snippets\css-snippets.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<IncludeInVSIX>true</IncludeInVSIX>
</Content>
<Content Include="Snippets\css-supported-file-types.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<IncludeInVSIX>true</IncludeInVSIX>
</Content>
<Content Include="Snippets\html-snippets.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<IncludeInVSIX>true</IncludeInVSIX>
</Content>
<Content Include="Snippets\html-supported-file-types.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<IncludeInVSIX>true</IncludeInVSIX>
</Content>
<Content Include="Snippets\variables.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<IncludeInVSIX>true</IncludeInVSIX>
</Content>
<Content Include="Snippets\xsl-snippets.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<IncludeInVSIX>true</IncludeInVSIX>
</Content>
<Content Include="Snippets\xsl-supported-file-types.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<IncludeInVSIX>true</IncludeInVSIX>
</Content>
<None Include="source.extension.vsixmanifest">
<SubType>Designer</SubType>
Expand Down Expand Up @@ -202,7 +209,7 @@
<IncludeAssets>compile; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="EmmetNetSharp">
<Version>1.0.0</Version>
<Version>1.0.1</Version>
<GeneratePathProperty>True</GeneratePathProperty>
</PackageReference>
<PackageReference Include="Microsoft.VSSDK.BuildTools" Version="17.0.5232" />
Expand Down
17 changes: 10 additions & 7 deletions EmmetVS/Helpers/ExtensionInitializationHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.ComponentModel.Design;
using System.IO;
using System.Linq;
using System.Reflection;

namespace EmmetVS.Helpers;

Expand All @@ -19,15 +20,17 @@ internal static async Task CheckDefaultInstallationOptionsAsync()
if (RuntimeOptions.Instance.DefaultValuesSet)
return;

var htmlSnippets = JsonConvert.DeserializeObject<Dictionary<string, string>>(File.ReadAllText(SnippetDefaults.HtmlSnippetsLocation) ?? string.Empty);
var cssSnippets = JsonConvert.DeserializeObject<Dictionary<string, string>>(File.ReadAllText(SnippetDefaults.CssSnippetsLocation) ?? string.Empty);
var xslSnippets = JsonConvert.DeserializeObject<Dictionary<string, string>>(File.ReadAllText(SnippetDefaults.XslSnippetsLocation) ?? string.Empty);
var assemblyPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

var htmlSupportedFileTypes = JsonConvert.DeserializeObject<List<string>>(File.ReadAllText(SnippetDefaults.HtmlSupportedFileTypesLocation) ?? string.Empty);
var cssSupportedFileTypes = JsonConvert.DeserializeObject<List<string>>(File.ReadAllText(SnippetDefaults.CssSupportedFileTypesLocation) ?? string.Empty);
var xslSupportedFileTypes = JsonConvert.DeserializeObject<List<string>>(File.ReadAllText(SnippetDefaults.XslSupportedFileTypesLocation) ?? string.Empty);
var htmlSnippets = JsonConvert.DeserializeObject<Dictionary<string, string>>(File.ReadAllText(Path.Combine(assemblyPath, SnippetDefaults.HtmlSnippetsLocation)) ?? string.Empty);
var cssSnippets = JsonConvert.DeserializeObject<Dictionary<string, string>>(File.ReadAllText(Path.Combine(assemblyPath, SnippetDefaults.CssSnippetsLocation)) ?? string.Empty);
var xslSnippets = JsonConvert.DeserializeObject<Dictionary<string, string>>(File.ReadAllText(Path.Combine(assemblyPath, SnippetDefaults.XslSnippetsLocation)) ?? string.Empty);

var variables = JsonConvert.DeserializeObject<Dictionary<string, string>>(File.ReadAllText(SnippetDefaults.VariablesLocation) ?? string.Empty);
var htmlSupportedFileTypes = JsonConvert.DeserializeObject<List<string>>(File.ReadAllText(Path.Combine(assemblyPath, SnippetDefaults.HtmlSupportedFileTypesLocation)) ?? string.Empty);
var cssSupportedFileTypes = JsonConvert.DeserializeObject<List<string>>(File.ReadAllText(Path.Combine(assemblyPath, SnippetDefaults.CssSupportedFileTypesLocation)) ?? string.Empty);
var xslSupportedFileTypes = JsonConvert.DeserializeObject<List<string>>(File.ReadAllText(Path.Combine(assemblyPath, SnippetDefaults.XslSupportedFileTypesLocation)) ?? string.Empty);

var variables = JsonConvert.DeserializeObject<Dictionary<string, string>>(File.ReadAllText(Path.Combine(assemblyPath, SnippetDefaults.VariablesLocation)) ?? string.Empty);

if (htmlSnippets is not null && htmlSnippets.Any())
{
Expand Down
18 changes: 10 additions & 8 deletions EmmetVS/Snippets/SnippetDefaults.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace EmmetVS.Snippets;
using System.IO;

namespace EmmetVS.Snippets;

/// <summary>
/// Represents the snippet locations
Expand All @@ -13,35 +15,35 @@ public static class SnippetDefaults
/// <summary>
/// Gets the HTML snippets file location
/// </summary>
public static string HtmlSnippetsLocation = $"{SnippetsDirectory}/html-snippets.json";
public static string HtmlSnippetsLocation = Path.Combine(SnippetsDirectory, "html-snippets.json");

/// <summary>
/// Gets the HTML supported file types file location
/// </summary>
public static string HtmlSupportedFileTypesLocation = $"{SnippetsDirectory}/html-supported-file-types.json";
public static string HtmlSupportedFileTypesLocation = Path.Combine(SnippetsDirectory, "html-supported-file-types.json");

/// <summary>
/// Gets the CSS snippets file location
/// </summary>
public static string CssSnippetsLocation = $"{SnippetsDirectory}/css-snippets.json";
public static string CssSnippetsLocation = Path.Combine(SnippetsDirectory, "css-snippets.json");

/// <summary>
/// Gets the CSS supported file types file location
/// </summary>
public static string CssSupportedFileTypesLocation = $"{SnippetsDirectory}/css-supported-file-types.json";
public static string CssSupportedFileTypesLocation = Path.Combine(SnippetsDirectory, "css-supported-file-types.json");

/// <summary>
/// Gets the XSL snippets file location
/// </summary>
public static string XslSnippetsLocation = $"{SnippetsDirectory}/xsl-snippets.json";
public static string XslSnippetsLocation = Path.Combine(SnippetsDirectory, "xsl-snippets.json");

/// <summary>
/// Gets the XSL supported file types file location
/// </summary>
public static string XslSupportedFileTypesLocation = $"{SnippetsDirectory}/xsl-supported-file-types.json";
public static string XslSupportedFileTypesLocation = Path.Combine(SnippetsDirectory, "xsl-supported-file-types.json");

/// <summary>
/// Gets the variables file location
/// </summary>
public static string VariablesLocation = $"{SnippetsDirectory}/variables.json";
public static string VariablesLocation = Path.Combine(SnippetsDirectory, "variables.json");
}
2 changes: 1 addition & 1 deletion EmmetVS/source.extension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ internal sealed partial class Vsix
public const string Name = "EmmetVS";
public const string Description = @"Supercharge your Visual Studio environment with the power of Emmet! Effortlessly expand abbreviations into complex HTML/XML and CSS code snippets. Streamline your web development process and elevate your coding efficiency like never before.";
public const string Language = "en-US";
public const string Version = "1.0.0";
public const string Version = "1.0.1";
public const string Author = "Amadej Glasenčnik";
public const string Tags = "visual-studio, vsix, emmet, html, css, xml, snippets, tools";
}
Expand Down
2 changes: 1 addition & 1 deletion EmmetVS/source.extension.vsixmanifest
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" ?>
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
<Metadata>
<Identity Id="EmmetVS.45ebdcc6-7813-4798-be08-7fbe376c5d47" Version="1.0.0" Language="en-US" Publisher="Amadej Glasenčnik" />
<Identity Id="EmmetVS.45ebdcc6-7813-4798-be08-7fbe376c5d47" Version="1.0.1" Language="en-US" Publisher="Amadej Glasenčnik" />
<DisplayName>EmmetVS</DisplayName>
<Description xml:space="preserve">Supercharge your Visual Studio environment with the power of Emmet! Effortlessly expand abbreviations into complex HTML/XML and CSS code snippets. Streamline your web development process and elevate your coding efficiency like never before.</Description>
<MoreInfo>https://github.com/aglasencnik/EmmetVS</MoreInfo>
Expand Down

0 comments on commit ed71ecd

Please sign in to comment.