Skip to content

Commit 9cfd1d4

Browse files
committed
fix: CommandPaletteDataTemplates should only used for command palettes
Signed-off-by: leo <longshuang@msn.cn>
1 parent ca7b674 commit 9cfd1d4

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/Views/Launcher.axaml.cs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,22 @@ namespace SourceGit.Views
1313
{
1414
public class CommandPaletteDataTemplates : IDataTemplate
1515
{
16-
public Control Build(object param) => App.CreateViewForViewModel(param);
17-
public bool Match(object data) => true;
16+
public Control Build(object param)
17+
{
18+
return App.CreateViewForViewModel(param);
19+
}
20+
21+
public bool Match(object data)
22+
{
23+
if (data is not IDisposable)
24+
return false;
25+
26+
var name = data.GetType().FullName;
27+
if (!name.EndsWith("CommandPalette", StringComparison.Ordinal) || !name.Contains(".ViewModels.", StringComparison.Ordinal))
28+
return false;
29+
30+
return true;
31+
}
1832
}
1933

2034
public partial class Launcher : ChromelessWindow

0 commit comments

Comments
 (0)