Skip to content

Commit f3ea33a

Browse files
committed
The last XPath query is being persisted and can be reused with the next query.
1 parent eeb0ed8 commit f3ea33a

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

src/features/xmlXPathEngine.ts

+22-1
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,17 @@ let resultChannel: OutputChannel = null;
99
export function evaluateXPath(editor: TextEditor, edit: TextEditorEdit): void {
1010
window.showInputBox({
1111
placeHolder: 'XPath Query',
12-
prompt: 'Please enter an XPath query to evaluate.'
12+
prompt: 'Please enter an XPath query to evaluate.',
13+
value: Singleton.getXPathValue()
1314

1415
}).then((query) => {
1516
if (query === undefined) return;
1617

1718
let xml = editor.document.getText();
1819
let doc = new dom().parseFromString(xml);
1920

21+
Singleton.setXPathValue(query);
22+
2023
try {
2124
var nodes = xpath.select(query, doc);
2225
}
@@ -42,4 +45,22 @@ export function evaluateXPath(editor: TextEditor, edit: TextEditorEdit): void {
4245

4346
resultChannel.show(ViewColumn.Three);
4447
});
48+
}
49+
50+
namespace Singleton {
51+
52+
class XPathContext
53+
{
54+
static _lastXPathValue:string = '';
55+
}
56+
57+
export function getXPathValue():string
58+
{
59+
return XPathContext._lastXPathValue;
60+
}
61+
62+
export function setXPathValue(val:string):void
63+
{
64+
XPathContext._lastXPathValue = val;
65+
}
4566
}

0 commit comments

Comments
 (0)