Skip to content

Commit e053060

Browse files
committed
🚸 [2.1.78] Docs: Preserve search filter
1 parent efbd27a commit e053060

File tree

4 files changed

+23
-38
lines changed

4 files changed

+23
-38
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
The following enhancements and changes have been made to ***Auto Build Marlin***.
44

5+
## 2.1.78
6+
- Docs Panel: Preserve last-used search filter
7+
- Docs Panel: Use Flexbox layout, improve link bounds
8+
- Schema: Clean up 'requires' clauses, empty comments
9+
- Schema: Developer flag to export schema as JSON
10+
511
## 2.1.77
612
- Docs Panel: Replacing "Info" panel
713
- Docs Panel: Filter now includes group name

abm/abm.js

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -38,30 +38,6 @@ function init(c) {
3838
set_context('inited', true);
3939
}
4040

41-
/**
42-
* The simplest layout concept is to take the entire config
43-
* and parse it in a big list. Parent items are at root, and
44-
* those with children have a colored background and a
45-
* "reveal" widget. Child items should be compact so we can fit
46-
* 2-3 fields across. Grouped (XYZE) items need to align left.
47-
*
48-
* I do want to make the layouts customized for each configuration,
49-
* but I also want the flexibility to grab fields from the config
50-
* files as they change. So, my idea is simply to wrap all the fields
51-
* in span containers. To create the panel, we send all the fields
52-
* in the relevant section to the web view script as soon as the panel
53-
* is selected. The web view takes care of creating the fields, adding
54-
* them to the DOM, and showing the panel. The CSS uses a FLEX layout
55-
* with certain named spans included, while the ones not named in the
56-
* layout will be placed into the "fallback" location, probably down
57-
* at the bottom.
58-
*
59-
* For the Geometry panel a simple hook is added to update the canvas
60-
* whenever the fields are updated. And the canvas has interactive bits
61-
* that update the geometry fields. If there is a pause of a few seconds
62-
* or the panel is switched then the changes are applied to the configs.
63-
*/
64-
6541
// Return the path to the given item within the build folder.
6642
function envSubPath(sub, env, item) {
6743
var bp = path.join(marlin.workspaceRoot, '.pio', sub, env);

abm/js/docsview.js

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,14 @@ function log(message, data) {
2121
if (data !== undefined) console.dir(data);
2222
}
2323

24+
// Save the current view state.
25+
// Use this to restore the view when it is revealed.
2426
var docs_filter = "";
27+
function saveWebViewState() {
28+
const data = { filter: docs_filter };
29+
log('saveWebViewState', data);
30+
vscode.setState(data);
31+
}
2532

2633
//
2734
// Declare a marlinfwSearch singleton
@@ -85,9 +92,6 @@ var marlinfwSearch = (() => {
8592
if (k >= 32 || k == 8) self.onSearchKeyUp();
8693
})
8794

88-
// Search the provided string on load
89-
self.searchFromField();
90-
9195
// Focus the search field, and also select all chars
9296
$searchInput.focus().select();
9397
},
@@ -97,6 +101,12 @@ var marlinfwSearch = (() => {
97101
return $searchInput.val().trim();
98102
},
99103

104+
// Set the search field value
105+
setFilter: (val) => {
106+
$searchInput.val(val).select().focus();
107+
self.searchFromField();
108+
},
109+
100110
// Convert a string to a regex pattern
101111
searchPattern: (str) => {
102112
const patt = str.toLowerCase().replace(ignore_pattern, '').trim().replace(/\s+/gm, '.+').replace(/([([\\])/gm, '\\$1');
@@ -141,6 +151,7 @@ var marlinfwSearch = (() => {
141151
if (newq == '') return;
142152

143153
docs_filter = newq;
154+
saveWebViewState();
144155
qmatch = newm;
145156

146157
let resultsCount = 0, results = '', prevclass = '';
@@ -229,14 +240,6 @@ $(function () {
229240
marlinfwSearch.init();
230241
}
231242

232-
// Save the current view state.
233-
// Use this to restore the view when it is revealed.
234-
function saveWebViewState() {
235-
const data = { data: {} };
236-
log('saveWebViewState', data);
237-
vscode.setState(data);
238-
}
239-
240243
/**
241244
* @brief Handle messages sent from the provider with iview.postMessage(msg)
242245
* @description Handle 'message' events sent directly to the view.
@@ -275,9 +278,9 @@ $(function () {
275278
const state = vscode.getState();
276279
if (state) {
277280
log("Got VSCode state", state);
278-
if ('data' in state) {
281+
if ('filter' in state) {
279282
log("Init Marlin Docs Webview with stored data")
280-
initDocsView();
283+
marlinfwSearch.setFilter(state.filter);
281284
}
282285
}
283286

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "auto-build",
33
"displayName": "Auto Build Marlin",
44
"description": "Provides an interface to configure, build, and upload Marlin Firmware.",
5-
"version": "2.1.77",
5+
"version": "2.1.78",
66
"preview": false,
77
"publisher": "marlinfirmware",
88
"icon": "icon.png",

0 commit comments

Comments
 (0)