Skip to content

Commit

Permalink
! Detected supported files in Output Smart Bar
Browse files Browse the repository at this point in the history
  • Loading branch information
wmjordan committed Dec 16, 2018
1 parent e0d0254 commit e19ceb2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
3 changes: 3 additions & 0 deletions Codist/Helpers/ServicesHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ private ServicesHelper() {
[Import]
public IClassificationTypeRegistryService ClassificationTypeRegistry { get; private set; }

[Import]
public Microsoft.VisualStudio.Utilities.IFileExtensionRegistryService FileExtensionRegistry { get; private set; }

[Import]
public IEditorFormatMapService EditorFormatMap { get; private set; }

Expand Down
22 changes: 16 additions & 6 deletions Codist/SmartBars/OutputSmartBar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,14 @@ protected override void AddCommands(CancellationToken cancellationToken) {
Process.Start("Explorer.exe", "/select,\"" + s + "\"");
}
});
AddCommand(MyToolBar, KnownImageIds.VisualStudio, "Open file with Visual Studio", ctx => {
var s = TryGetPath(View);
if (s != null) {
CodistPackage.DTE.OpenFile(s, 1, 1);
}
});
if (IsFileTypeRegisteredInVS(t)) {
AddCommand(MyToolBar, KnownImageIds.VisualStudio, "Open file with Visual Studio", ctx => {
var s = TryGetPath(View);
if (s != null && IsFileTypeRegisteredInVS(s)) {
CodistPackage.DTE.OpenFile(s, 1, 1);
}
});
}
}
else if (Directory.Exists(t)) {
AddCommand(MyToolBar, KnownImageIds.OpenFolder, "Open folder", ctx => {
Expand Down Expand Up @@ -72,6 +74,14 @@ void TryRun(string path) {
// ignore
}
}
bool IsFileTypeRegisteredInVS(string fileName) {
try {
return ServicesHelper.Instance.FileExtensionRegistry.GetContentTypeForExtension(Path.GetExtension(fileName)).TypeName != "UNKNOWN";
}
catch (ArgumentException) {
return false;
}
}
}
}
}

0 comments on commit e19ceb2

Please sign in to comment.