Skip to content

Commit 25439b2

Browse files
committed
Work on issue #104 re: error form
Is probably resolved now Now hitting Enter when in the error form and using the "Refresh with current errors" right-click context item do the same thing, as they always should have done.
1 parent e5eef9b commit 25439b2

5 files changed

Lines changed: 89 additions & 78 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
6363
2. Minor bug where JsonTools could not set the text of a file to end with the SOH character (ASCII code `\x01`)
6464
3. Minor bug where some JsonGrepper tests would always fail because they queried an external API that had previously returned JSON but now returns HTML.
6565
4. Bug where editing a document in [multi-selection mode](/docs/README.md#working-with-selections) would sometimes cause selections to be forgotten (fixed in [v8.4.0.3](https://github.com/molsonkiko/JsonToolsNppPlugin/commit/16f0358274c662273a2015994c5ab22d22fd23ab))
66+
5. Bug ([issue 104](https://github.com/molsonkiko/JsonToolsNppPlugin/issues/104)) where [error form](/docs/README.md#error-form-and-status-bar) would not always re-parse the document after the `Refresh with current errors` right-click context menu item on the error form was clicked.
6667

6768
## [8.4.0] - 2025-05-04
6869

JsonToolsNppPlugin/Forms/ErrorForm.cs

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,39 @@ private void ErrorForm_RightClick(object sender, MouseEventArgs e)
166166
}
167167
}
168168

169+
/// <summary>
170+
/// does the following:<br></br>
171+
/// 1. temporarily suppress prompt asking if error form should be shown<br></br>
172+
/// 2. if automatic schema validation is desired, re-validate<br></br>
173+
/// 3. Re-parse the JSON<br></br>
174+
/// 4. Re-display the error form with all the lints found in steps 2 and 3
175+
/// </summary>
176+
private void RefreshWithContentsOfCurrentFile()
177+
{
178+
Main.errorFormTriggeredParse = true;
179+
// temporarily turn off offer_to_show_lint prompt, because the user obviously wants to see it
180+
bool previousOfferToShowLint = Main.settings.offer_to_show_lint;
181+
Main.settings.offer_to_show_lint = false;
182+
Main.TryParseJson(preferPreviousDocumentType: true);
183+
if (Main.TryGetInfoForFile(Main.activeFname, out JsonFileInfo info)
184+
&& info.lints != null)
185+
{
186+
if (info.filenameOfMostRecentValidatingSchema is null)
187+
Reload(Main.activeFname, info.lints);
188+
else
189+
{
190+
Main.ValidateJson(info.filenameOfMostRecentValidatingSchema, false);
191+
if (Main.TryGetInfoForFile(Main.activeFname, out info) && info.lints != null && info.statusBarSection != null && info.statusBarSection.Contains("fatal errors"))
192+
Reload(Main.activeFname, info.lints);
193+
}
194+
}
195+
Main.settings.offer_to_show_lint = previousOfferToShowLint;
196+
Main.errorFormTriggeredParse = false;
197+
}
198+
169199
private void RefreshMenuItem_Click(object sender, EventArgs e)
170200
{
171-
Npp.notepad.HideDockingForm(this);
172-
Main.OpenErrorForm(Npp.notepad.GetCurrentFilePath(), false);
201+
RefreshWithContentsOfCurrentFile();
173202
}
174203

175204
private void ExportLintsToJsonMenuItem_Click(object sender, EventArgs e)
@@ -203,27 +232,8 @@ private void ErrorForm_KeyUp(object sender, KeyEventArgs e)
203232
{
204233
if (e.KeyCode == Keys.Enter)
205234
{
206-
// refresh error form based on current contents of current file
207235
e.Handled = true;
208-
Main.errorFormTriggeredParse = true;
209-
// temporarily turn off offer_to_show_lint prompt, because the user obviously wants to see it
210-
bool previousOfferToShowLint = Main.settings.offer_to_show_lint;
211-
Main.settings.offer_to_show_lint = false;
212-
Main.TryParseJson(preferPreviousDocumentType:true);
213-
if (Main.TryGetInfoForFile(Main.activeFname, out JsonFileInfo info)
214-
&& info.lints != null)
215-
{
216-
if (info.filenameOfMostRecentValidatingSchema is null)
217-
Reload(Main.activeFname, info.lints);
218-
else
219-
{
220-
Main.ValidateJson(info.filenameOfMostRecentValidatingSchema, false);
221-
if (Main.TryGetInfoForFile(Main.activeFname, out info) && info.lints != null && info.statusBarSection != null && info.statusBarSection.Contains("fatal errors"))
222-
Reload(Main.activeFname, info.lints);
223-
}
224-
}
225-
Main.settings.offer_to_show_lint = previousOfferToShowLint;
226-
Main.errorFormTriggeredParse = false;
236+
RefreshWithContentsOfCurrentFile();
227237
return;
228238
}
229239
else if (e.KeyCode == Keys.Escape)

JsonToolsNppPlugin/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@
2828
// Build Number
2929
// Revision
3030
//
31-
[assembly: AssemblyVersion("8.4.0.3")]
32-
[assembly: AssemblyFileVersion("8.4.0.3")]
31+
[assembly: AssemblyVersion("8.4.0.4")]
32+
[assembly: AssemblyFileVersion("8.4.0.4")]

docs/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,11 +194,11 @@ As the above example shows, this method *can* handle unmatched quotes/braces, bu
194194

195195
### Error form and status bar ###
196196

197-
If you click "Yes", a docking form will open up at the bottom of the document. Each row in the document will correspond to a different syntax error.
197+
If you respond "Yes" to the prompt that appears after parsing JSON with errors, a docking form will open up at the bottom of the document. Each row in the document will correspond to a different syntax error.
198198

199199
Clicking on or paging to a row in the error form with the arrow keys will move the caret to the location in the document where that error was found.
200200

201-
Hitting `Enter` while in the form refreshes the form with the JSON in the current document. You can also seek the next syntax error with a description that starts with a letter by typing that letter while in the form. For example, typing `P` in the form might select the next `Python-style '#' comments are not part of any well-accepted JSON specification` error.
201+
Hitting `Enter` or choosing the `Refresh with current errors` right-click context menu item while in the form refreshes the form with the JSON in the current document. You can also seek the next syntax error with a description that starts with a letter by typing that letter while in the form. For example, typing `P` in the form might select the next `Python-style '#' comments are not part of any well-accepted JSON specification` error.
202202

203203
Beginning in [v6.0](/CHANGELOG.md#600---2023-12-13), you can right-click on this form to gain the option of exporting all errors to JSON or refreshing the form.
204204

0 commit comments

Comments
 (0)