Skip to content

Commit 1ac5795

Browse files
committed
smaller whitespace checkin
1 parent 6328ff1 commit 1ac5795

File tree

6 files changed

+63
-21
lines changed

6 files changed

+63
-21
lines changed

src/modules/cmdpal/src/Microsoft.CmdPal.Common/Services/LocalSettingsService.cs

+5-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public class LocalSettingsService : ILocalSettingsService
3535

3636
public LocalSettingsService(IFileService fileService, IOptions<LocalSettingsOptions> options)
3737
{
38-
_isMsix = false;// RuntimeHelper.IsMSIX;
38+
_isMsix = false; // RuntimeHelper.IsMSIX;
3939

4040
_fileService = fileService;
4141
_options = options.Value;
@@ -91,8 +91,11 @@ public async Task<bool> HasSettingAsync(string key)
9191
if (_settings != null && _settings.TryGetValue(key, out var obj))
9292
{
9393
var s = obj.ToString();
94-
if (s !=null)
94+
95+
if (s != null)
96+
{
9597
return await Json.ToObjectAsync<T>(s);
98+
}
9699
}
97100
}
98101

src/modules/cmdpal/src/WindowsCommandPalette/BookmarkActions.cs

+9-2
Original file line numberDiff line numberDiff line change
@@ -155,15 +155,22 @@ public override ActionResult SubmitForm(string payload)
155155
var state = File.ReadAllText(BookmarksActionProvider.StateJsonPath());
156156
var jsonState = JsonNode.Parse(state);
157157
var items = jsonState?["items"]?.AsArray();
158+
158159
if (items != null)
159160
{
160161
// var items = jsonState["items"];
161162
var newItem = new JsonObject();
162163
newItem["name"] = formName;
163164
newItem["bookmark"] = formBookmark;
164-
var formData = new BookmarkData() { name = formName.ToString(), bookmark=formBookmark.ToString(), type = bookmarkType };
165+
var formData = new BookmarkData()
166+
{
167+
name = formName.ToString(),
168+
bookmark = formBookmark.ToString(),
169+
type = bookmarkType,
170+
};
171+
165172
items.Add(JsonSerializer.SerializeToNode(formData, typeof(BookmarkData), SourceGenerationContext.Default));
166-
//items.Add(newItem);
173+
167174
json = jsonState?.ToString();
168175
}
169176
}

src/modules/cmdpal/src/WindowsCommandPalette/ListItemViewModel.cs

+24-2
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,44 @@ namespace DeveloperCommandPalette;
1313
public sealed class ListItemViewModel : INotifyPropertyChanged, IDisposable
1414
{
1515
private readonly DispatcherQueue DispatcherQueue;
16+
1617
internal ExtensionObject<IListItem> ListItem { get; init; }
18+
1719
internal string Title { get; private set; }
20+
1821
internal string Subtitle { get; private set; }
22+
1923
internal string Icon { get; private set; }
2024

2125
internal Lazy<DetailsViewModel?> _Details;
26+
2227
internal DetailsViewModel? Details => _Details.Value;
2328

2429
public event PropertyChangedEventHandler? PropertyChanged;
2530

26-
internal ICommand? DefaultAction { get {try{ return ListItem.Unsafe.Command;} catch (COMException){return null;}}}
31+
internal ICommand? DefaultAction
32+
{
33+
get
34+
{
35+
try
36+
{
37+
return ListItem.Unsafe.Command;
38+
}
39+
catch (COMException)
40+
{
41+
return null;
42+
}
43+
}
44+
}
2745

2846
internal bool CanInvoke => DefaultAction != null && DefaultAction is IInvokableCommand or IPage;
47+
2948
internal IconElement IcoElement => Microsoft.Terminal.UI.IconPathConverter.IconMUX(Icon);
3049

3150
private IEnumerable<ICommandContextItem> contextActions
3251
{
33-
get {
52+
get
53+
{
3454
try
3555
{
3656
var item = ListItem.Unsafe;
@@ -45,9 +65,11 @@ private IEnumerable<ICommandContextItem> contextActions
4565
}
4666
}
4767
}
68+
4869
internal bool HasMoreCommands => contextActions.Any();
4970

5071
internal TagViewModel[] Tags = [];
72+
5173
internal bool HasTags => Tags.Length > 0;
5274

5375
internal IList<ContextItemViewModel> ContextActions

src/modules/cmdpal/src/WindowsCommandPalette/ListPage.xaml.cs

+5-4
Original file line numberDiff line numberDiff line change
@@ -158,19 +158,20 @@ internal async Task UpdateListItems()
158158
var sectionItems = new SectionInfoList(
159159
section,
160160
section.Items
161-
.Where(i=>i!= null && !string.IsNullOrEmpty(i.Title))
161+
.Where(i => i != null && !string.IsNullOrEmpty(i.Title))
162162
.Select(i => new ListItemViewModel(i))
163163
);
164+
164165
// var items = section.Items;
165166
// for (var i = 0; i < items.Length; i++) {
166167
// ListItemViewModel vm = new(items[i]);
167168
// Items.Add(vm);
168169
// FilteredItems.Add(vm);
169170
// }
170-
171171
newItems.Add(sectionItems);
172-
//Items.Add(sectionItems);
173-
//FilteredItems.Add(sectionItems);
172+
173+
// Items.Add(sectionItems);
174+
// FilteredItems.Add(sectionItems);
174175
}
175176

176177
ListHelpers.InPlaceUpdateList(Items, newItems);

src/modules/cmdpal/src/WindowsCommandPalette/MainPage.xaml.cs

+17-10
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public sealed class MainViewModel
3131
internal bool LoadedApps;
3232

3333
public event TypedEventHandler<object, object?>? HideRequested;
34-
34+
3535
public event TypedEventHandler<object, object?>? SummonRequested;
3636

3737
public event TypedEventHandler<object, object?>? AppsReady;
@@ -65,7 +65,8 @@ internal void RequestHide()
6565
handlers?.Invoke(this, null);
6666
}
6767

68-
public void Summon(){
68+
public void Summon()
69+
{
6970
var handlers = SummonRequested;
7071
handlers?.Invoke(this, null);
7172
}
@@ -75,20 +76,26 @@ private static string CreateHash(string? title, string? subtitle)
7576
return title + subtitle;
7677
}
7778

78-
private string[] _recentCommandHashes = [];// ["SpotifySpotify", "All Apps", "GitHub Issues", "Microsoft/GithubBookmark"];
79+
private string[] _recentCommandHashes = [];
7980

8081
public IEnumerable<IListItem> RecentActions => TopLevelCommands
81-
.Select(i=>i.Unsafe)
82-
.Where((i) => {
82+
.Select(i => i.Unsafe)
83+
.Where((i) =>
84+
{
8385
if (i != null)
8486
{
85-
try{
87+
try
88+
{
8689
return _recentCommandHashes.Contains(CreateHash(i.Title, i.Subtitle));
87-
} catch(COMException){ return false; }
90+
}
91+
catch (COMException)
92+
{
93+
return false;
94+
}
8895
}
96+
8997
return false;
90-
})
91-
.Select(i=>i!);
98+
}).Select(i => i!);
9299

93100
public IEnumerable<IListItem> AppItems => LoadedApps? apps.GetItems().First().Items : [];
94101

@@ -139,7 +146,7 @@ internal void PushRecentAction(ICommand action)
139146
return;
140147
}
141148
}
142-
catch(COMException){ /* log something */ }
149+
catch (COMException) { /* log something */ }
143150
}
144151
}
145152
}

src/modules/cmdpal/src/WindowsCommandPalette/SettingsActionProvider.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ private static async Task<string> GetSettingsDataJson()
8282
var hotkey = "win+ctrl+.";
8383
try
8484
{
85-
hotkey = await Application.Current.GetService<ILocalSettingsService>().ReadSettingAsync<string>("GlobalHotkey") ;
85+
hotkey = await Application.Current.GetService<ILocalSettingsService>().ReadSettingAsync<string>("GlobalHotkey");
8686
}
8787
catch (Exception ex)
8888
{
@@ -94,7 +94,9 @@ private static async Task<string> GetSettingsDataJson()
9494
}
9595
""";
9696
}
97+
9798
public override string StateJson() => throw new NotImplementedException();
99+
98100
public override ActionResult SubmitForm(string payload)
99101
{
100102
var formInput = JsonNode.Parse(payload)?.AsObject();

0 commit comments

Comments
 (0)