Skip to content

Commit

Permalink
Fixed Surround With menu availability issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
sergey-visual-studio committed Feb 25, 2023
1 parent 863969e commit d4af277
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 14 deletions.
6 changes: 3 additions & 3 deletions DPackRx.Tests/DPackRx.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@
<Version>6.4.0</Version>
</PackageReference>
<PackageReference Include="Microsoft.VisualStudio.SDK">
<Version>17.0.31902.203</Version>
<Version>17.4.33103.184</Version>
</PackageReference>
<PackageReference Include="Microsoft.VisualStudio.VCProjectEngine">
<Version>17.0.31902.203</Version>
<Version>17.4.33103.184</Version>
</PackageReference>
<PackageReference Include="Moq">
<Version>4.16.1</Version>
Expand All @@ -101,7 +101,7 @@
<Version>4.3.1</Version>
</PackageReference>
<PackageReference Include="VsWebSite.Interop90">
<Version>17.0.31902.203</Version>
<Version>17.4.33103.184</Version>
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
Expand Down
11 changes: 7 additions & 4 deletions DPackRx/DPackRx.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -331,15 +331,17 @@
<Version>6.4.0</Version>
</PackageReference>
<PackageReference Include="Microsoft.VisualStudio.SDK">
<Version>17.0.31902.203</Version>
<Version>17.4.33103.184</Version>
<ExcludeAssets>runtime</ExcludeAssets>
<IncludeAssets>compile; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.VisualStudio.VCProjectEngine">
<Version>17.0.31902.203</Version>
<Version>17.4.33103.184</Version>
<ExcludeAssets>runtime</ExcludeAssets>
<IncludeAssets>compile; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.VSSDK.BuildTools">
<Version>17.0.5232</Version>
<Version>17.4.2120</Version>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand All @@ -351,8 +353,9 @@
<Version>2.0.20525</Version>
</PackageReference>
<PackageReference Include="VsWebSite.Interop90">
<Version>17.0.31902.203</Version>
<Version>17.4.33103.184</Version>
<ExcludeAssets>runtime</ExcludeAssets>
<IncludeAssets>compile; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
Expand Down
3 changes: 2 additions & 1 deletion DPackRx/Features/SurroundWith/SurroundWithFeature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,15 @@ public override bool IsValidContext(int commandId)
if ((languageSet?.Type == LanguageType.Unknown) || !languageSet.SurroundWith)
return false;

return
var result =
_shellSelectionService.IsContextActive(ContextType.SolutionExists) && (
_shellSelectionService.IsContextActive(ContextType.TextEditor) ||
_shellSelectionService.IsContextActive(ContextType.XMLTextEditor) ||
_shellSelectionService.IsContextActive(ContextType.XamlEditor) ||
_shellSelectionService.IsContextActive(ContextType.NewXamlEditor) ||
_shellSelectionService.IsContextActive(ContextType.HTMLSourceEditor) ||
_shellSelectionService.IsContextActive(ContextType.CSSTextEditor));
return result;
default:
return base.IsValidContext(commandId);
}
Expand Down
7 changes: 6 additions & 1 deletion DPackRx/Language/LanguageRegistrationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class LanguageRegistrationService : ILanguageRegistrationService
private const string IGNORE_CODE_TYPE = "IgnoreCodeType";
private const string CHECK_DUPLICATE_NAMES = "CheckDuplicateNames";
private const string PARENTLESS_FULL_NAME = "ParentlessFullName";
private const string SURROUND_WITH = "SurroundWith";
private const string LOG_CATEGORY = "Language Registry";

#endregion
Expand Down Expand Up @@ -84,6 +85,7 @@ public ICollection<LanguageSettings> GetLanguages()
var parentlessFullName = false;
var designerFiles = LanguageDesignerFiles.NotSupported;
var imports = LanguageImports.NotSupported;
var surroundWith = false;

var langKey = dpackKey.OpenSubKey(id);
if (langKey != null)
Expand All @@ -107,6 +109,8 @@ public ICollection<LanguageSettings> GetLanguages()
(int)langKey.GetValue(CHECK_DUPLICATE_NAMES, Convert.ToInt32(checkDuplicateNames)));
parentlessFullName = Convert.ToBoolean(
(int)langKey.GetValue(PARENTLESS_FULL_NAME, Convert.ToInt32(parentlessFullName)));
surroundWith = Convert.ToBoolean(
(int)langKey.GetValue(SURROUND_WITH, Convert.ToInt32(surroundWith)));
}
}
if (string.IsNullOrEmpty(friendlyName))
Expand All @@ -126,7 +130,8 @@ public ICollection<LanguageSettings> GetLanguages()
Imports = imports,
IgnoreCodeType = ignoreCodeType,
CheckDuplicateNames = checkDuplicateNames,
ParentlessFullName = parentlessFullName
ParentlessFullName = parentlessFullName,
SurroundWith = surroundWith,
};

var extKey = dpackKey.OpenSubKey(id + "\\" + EXTENSIONS_KEY);
Expand Down
4 changes: 0 additions & 4 deletions DPackRx/Package/Registration/ProvideLanguageAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,6 @@ public ProvideLanguageAttribute(string productName, string languageGuid, string

public bool SurroundWith { get; set; }

public string SurroundWithLanguageName { get; set; }

internal string RegKeyName
{
get { return string.Format(@"{0}\Languages\{1}", _productName, _languageGuid); }
Expand Down Expand Up @@ -145,8 +143,6 @@ public override void Register(RegistrationContext context)
key.SetValue(nameof(this.ParentlessFullName), Convert.ToInt32(this.ParentlessFullName));
if (this.SurroundWith)
key.SetValue(nameof(this.SurroundWith), Convert.ToInt32(this.SurroundWith));
if (!string.IsNullOrEmpty(this.SurroundWithLanguageName))
key.SetValue(nameof(this.SurroundWithLanguageName), this.SurroundWithLanguageName);

if ((_extensions != null) && (_extensions.Length > 0))
{
Expand Down
2 changes: 1 addition & 1 deletion DPackRx/source.extension.vsixmanifest
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<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="3D22E261-32E5-46CE-A4B0-B884FA49A9A2.2022" Version="4.5.2.3" Language="en-US" Publisher="Sergey M" />
<Identity Id="3D22E261-32E5-46CE-A4B0-B884FA49A9A2.2022" Version="4.5.2.4" Language="en-US" Publisher="Sergey M" />
<DisplayName>DPack Rx 2022</DisplayName>
<Description xml:space="preserve">FREE tools collection designed to greatly increase developer's productivity, automate repetitive processes and expand upon some of Microsoft Visual Studio features.</Description>
<MoreInfo>https://github.com/sergey-visual-studio/dpack</MoreInfo>
Expand Down

0 comments on commit d4af277

Please sign in to comment.