Skip to content

Commit 4f3bc9f

Browse files
authored
Merge pull request #642 from TheJoeFin/dev
4.13.2 Dev
2 parents 69741ac + 4e7013f commit 4f3bc9f

13 files changed

Lines changed: 225 additions & 16 deletions

.claude/settings.local.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,13 @@
1212
"Bash(dotnet test:*)",
1313
"Bash(gh pr list:*)",
1414
"Bash(/mnt/c/Program Files/dotnet/dotnet.exe:*)",
15-
"WebFetch(domain:github.com)"
15+
"WebFetch(domain:github.com)",
16+
"Skill(pdm)",
17+
"Bash(mkdir -p bin)",
18+
"Bash(curl -o bin/pdm https://app.produckmap.com/cli/pdm)",
19+
"Bash(chmod +x bin/pdm)",
20+
"Bash(bin/pdm ui-element:*)",
21+
"Bash(bin/pdm *)"
1622
],
1723
"deny": []
1824
}

Tests/SettingsServiceTests.cs

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,77 @@ public void ClearingManagedSettingClearsLegacyAndSidecar()
133133
Assert.Empty(service.LoadStoredRegexes());
134134
}
135135

136+
[Fact]
137+
public void Constructor_FileBackedModeReflectsSettingsValueSetBeforeConstruction()
138+
{
139+
// EnableFileBackedManagedSettings must be read AFTER any migration so the
140+
// persisted user preference is honoured for the current session.
141+
Settings settings = new()
142+
{
143+
FirstRun = false,
144+
EnableFileBackedManagedSettings = true
145+
};
146+
147+
SettingsService service = CreateService(settings);
148+
149+
Assert.True(service.IsFileBackedManagedSettingsEnabled);
150+
}
151+
152+
[Fact]
153+
public void Constructor_FileBackedModeDefaultsToFalseWhenNotSet()
154+
{
155+
Settings settings = new()
156+
{
157+
FirstRun = false,
158+
EnableFileBackedManagedSettings = false
159+
};
160+
161+
SettingsService service = CreateService(settings);
162+
163+
Assert.False(service.IsFileBackedManagedSettingsEnabled);
164+
}
165+
166+
[Fact]
167+
public void Constructor_UnpackagedUpgradePathDoesNotThrowWhenNoPreviousVersion()
168+
{
169+
// When saveClassicSettingsChanges is false (test mode) the Upgrade() code path is
170+
// skipped, so this simply verifies that the constructor completes successfully when
171+
// FirstRun is true and localSettings is null.
172+
Settings settings = new()
173+
{
174+
FirstRun = true,
175+
EnableFileBackedManagedSettings = false
176+
};
177+
178+
SettingsService service = CreateService(settings);
179+
180+
// Service initialises without throwing; FileBackedMode reflects the setting.
181+
Assert.False(service.IsFileBackedManagedSettingsEnabled);
182+
}
183+
184+
[Fact]
185+
public void LoadStoredRegexes_SidecarSurvivesSimulatedPackageUpgrade()
186+
{
187+
// Simulate a package upgrade: sidecar file already exists (from the previous
188+
// version) but ClassicSettings.RegexList is empty (reset by the upgrade).
189+
// The service must load from the sidecar and backfill ClassicSettings.
190+
Settings settings = new()
191+
{
192+
FirstRun = false,
193+
EnableFileBackedManagedSettings = false,
194+
RegexList = string.Empty
195+
};
196+
string regexFilePath = Path.Combine(_tempFolder, "RegexList.json");
197+
File.WriteAllText(regexFilePath, SerializeRegexes("survived-upgrade"));
198+
199+
SettingsService service = CreateService(settings);
200+
201+
StoredRegex loaded = Assert.Single(service.LoadStoredRegexes());
202+
Assert.Equal("survived-upgrade", loaded.Id);
203+
// Verify backfill into ClassicSettings so the next migration has something to copy.
204+
Assert.Contains("survived-upgrade", settings.RegexList);
205+
}
206+
136207
private SettingsService CreateService(Settings settings) =>
137208
new(
138209
settings,

Tests/Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<PrivateAssets>all</PrivateAssets>
1818
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1919
</PackageReference>
20-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.3.0" />
20+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.4.0" />
2121
<PackageReference Include="Moq" Version="4.20.72" />
2222
<PackageReference Include="NCalcAsync" Version="5.12.0" />
2323
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.5">

Text-Grab-Package/Package.appxmanifest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<Identity
1515
Name="40087JoeFinApps.TextGrab"
1616
Publisher="CN=153F3B0F-BA3D-4964-8098-71AC78A1DF6A"
17-
Version="4.13.0.0" />
17+
Version="4.13.2.0" />
1818

1919
<Properties>
2020
<DisplayName>Text Grab</DisplayName>

Text-Grab/Models/ButtonInfo.cs

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -127,13 +127,6 @@ public static List<ButtonInfo> DefaultButtonList
127127
SymbolIcon = SymbolRegular.Copy24
128128
},
129129
new()
130-
{
131-
ButtonText = "Save to File...",
132-
SymbolText = "",
133-
ClickEvent = "SaveBTN_Click",
134-
SymbolIcon = SymbolRegular.Save24
135-
},
136-
new()
137130
{
138131
ButtonText = "Make Single Line",
139132
SymbolText = "",
@@ -215,6 +208,14 @@ public static List<ButtonInfo> AllButtons
215208
SymbolIcon = SymbolRegular.DocumentSave24
216209
},
217210
new()
211+
{
212+
OrderNumber = 1.21,
213+
ButtonText = "Save As...",
214+
SymbolText = "",
215+
ClickEvent = "SaveAsBTN_Click",
216+
SymbolIcon = SymbolRegular.DocumentEdit24
217+
},
218+
new()
218219
{
219220
OrderNumber = 1.3,
220221
ButtonText = "Make Single Line",
@@ -239,6 +240,14 @@ public static List<ButtonInfo> AllButtons
239240
SymbolIcon = SymbolRegular.Timer324
240241
},
241242
new()
243+
{
244+
OrderNumber = 1.42,
245+
ButtonText = "Manage Grab Templates...",
246+
SymbolText = "",
247+
ClickEvent = "ManageGrabTemplates_Click",
248+
SymbolIcon = SymbolRegular.GridDots24
249+
},
250+
new()
242251
{
243252
OrderNumber = 1.5,
244253
ButtonText = "Open Grab Frame",
@@ -415,6 +424,14 @@ public static List<ButtonInfo> AllButtons
415424
SymbolIcon = SymbolRegular.TextWrap24
416425
},
417426
new()
427+
{
428+
OrderNumber = 4.51,
429+
ButtonText = "Split Lines After Each Selection",
430+
SymbolText = "",
431+
Command = "SplitAfterSelectionCmd",
432+
SymbolIcon = SymbolRegular.TextWrapOff24
433+
},
434+
new()
418435
{
419436
OrderNumber = 4.6,
420437
ButtonText = "Isolate Selection",

Text-Grab/Models/ShortcutKeySet.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,14 @@ public override int GetHashCode()
175175
Name = "Edit last Grab Frame",
176176
Action = ShortcutKeyActions.PreviousGrabFrame
177177
},
178+
new()
179+
{
180+
Modifiers = {KeyModifiers.Windows, KeyModifiers.Shift, KeyModifiers.Control},
181+
NonModifierKey = Key.V,
182+
IsEnabled = true,
183+
Name = "Open Clipboard Content",
184+
Action = ShortcutKeyActions.OpenClipboardContent
185+
},
178186
};
179187
}
180188

@@ -189,4 +197,5 @@ public enum ShortcutKeyActions
189197
PreviousRegionGrab = 6,
190198
PreviousEditWindow = 7,
191199
PreviousGrabFrame = 8,
200+
OpenClipboardContent = 9,
192201
}

Text-Grab/Pages/KeysSettings.xaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@
7979
KeySetChanged="ShortcutControl_KeySetChanged"
8080
RecordingStarted="ShortcutControl_Recording"
8181
ShortcutName="Quick Simple Lookup" />
82+
<controls:ShortcutControl
83+
x:Name="OccShortcutControl"
84+
KeySetChanged="ShortcutControl_KeySetChanged"
85+
RecordingStarted="ShortcutControl_Recording"
86+
ShortcutName="Open Clipboard Content" />
8287
</StackPanel>
8388
</StackPanel>
8489
</Page>

Text-Grab/Pages/KeysSettings.xaml.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,9 @@ private void Page_Loaded(object sender, RoutedEventArgs e)
136136
case ShortcutKeyActions.PreviousGrabFrame:
137137
LgfShortcutControl.KeySet = keySet;
138138
break;
139+
case ShortcutKeyActions.OpenClipboardContent:
140+
OccShortcutControl.KeySet = keySet;
141+
break;
139142
default:
140143
break;
141144
}

Text-Grab/Services/SettingsService.cs

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,27 @@ internal SettingsService(
6464
_localSettings = localSettings;
6565
_managedJsonSettingsFolderPath = managedJsonSettingsFolderPath ?? GetManagedJsonSettingsFolderPath();
6666
_saveClassicSettingsChanges = saveClassicSettingsChanges;
67-
_preferFileBackedManagedSettings = ClassicSettings.EnableFileBackedManagedSettings;
6867

69-
if (ClassicSettings.FirstRun && _localSettings is not null && _localSettings.Values.Count > 0)
70-
MigrateLocalSettingsToClassic();
68+
if (ClassicSettings.FirstRun)
69+
{
70+
if (_localSettings is not null && _localSettings.Values.Count > 0)
71+
{
72+
// Packaged: ApplicationDataContainer persists across package upgrades,
73+
// so copy saved values back into the freshly-reset classic settings.
74+
MigrateLocalSettingsToClassic();
75+
if (_saveClassicSettingsChanges)
76+
ClassicSettings.Save();
77+
}
78+
else if (_localSettings is null && _saveClassicSettingsChanges)
79+
{
80+
// Unpackaged: Properties.Settings stores data in a version-specific path,
81+
// so call Upgrade() to carry forward values from the previous version.
82+
ClassicSettings.Upgrade();
83+
}
84+
}
85+
86+
// Must be read after any migration so the user's saved preference is respected.
87+
_preferFileBackedManagedSettings = ClassicSettings.EnableFileBackedManagedSettings;
7188

7289
// copy settings from classic to local settings
7390
// so that when app updates they can be copied forward

Text-Grab/Text-Grab.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
2424
<RuntimeIdentifiers>win-x86;win-x64;win-arm64</RuntimeIdentifiers>
2525
<EnableMsixTooling>false</EnableMsixTooling>
26-
<Version>4.13.0</Version>
26+
<Version>4.13.2</Version>
2727
</PropertyGroup>
2828

2929
<ItemGroup>
@@ -52,7 +52,7 @@
5252

5353
<ItemGroup>
5454
<PackageReference Include="CliWrap" Version="3.10.1" />
55-
<PackageReference Include="Dapplo.Windows.User32" Version="2.0.85" />
55+
<PackageReference Include="Dapplo.Windows.User32" Version="2.0.89" />
5656
<PackageReference Include="Humanizer.Core" Version="3.0.10" />
5757
<PackageReference Include="Magick.NET-Q16-AnyCPU" Version="14.11.1" />
5858
<PackageReference Include="Magick.NET.SystemDrawing" Version="8.0.19" />

0 commit comments

Comments
 (0)