Skip to content

Commit 9793f1d

Browse files
Merge pull request #542 from X-Sharp/master
Add overload for InterceptAsync with a command name, because some com… [release]
2 parents 5301fca + 21090e9 commit 9793f1d

File tree

1 file changed

+13
-0
lines changed
  • src/toolkit/Community.VisualStudio.Toolkit.Shared/Commands

1 file changed

+13
-0
lines changed

src/toolkit/Community.VisualStudio.Toolkit.Shared/Commands/Commands.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,19 @@ public async Task<IDisposable> InterceptAsync(CommandID cmd, Func<CommandProgres
125125

126126
return new Disposable(() => priority.UnregisterPriorityCommandTarget(cookie));
127127
}
128+
/// <summary>
129+
/// Intercept any command before it is being handled by other command handlers.
130+
/// </summary>
131+
/// <returns>Returns an <see cref="IDisposable"/> that will remove the command interceptor when disposed.</returns>
132+
public async Task<IDisposable> InterceptAsync(string name, Func<CommandProgression> func)
133+
{
134+
CommandID? cmd = await FindCommandAsync(name);
135+
if (cmd == null)
136+
{
137+
throw new ArgumentException($"Command '{name}' not found.");
138+
}
139+
return await InterceptAsync(cmd, func);
140+
}
128141
}
129142

130143
internal class CommandInterceptor : IOleCommandTarget

0 commit comments

Comments
 (0)