The last XPath query is being persisted and can be reused with the next query.

This commit is contained in:
Rajko Winkler 2015-12-16 15:54:48 +01:00
parent eeb0ed8d4c
commit f3ea33a522
1 changed files with 22 additions and 1 deletions

View File

@ -9,7 +9,8 @@ let resultChannel: OutputChannel = null;
export function evaluateXPath(editor: TextEditor, edit: TextEditorEdit): void {
window.showInputBox({
placeHolder: 'XPath Query',
prompt: 'Please enter an XPath query to evaluate.'
prompt: 'Please enter an XPath query to evaluate.',
value: Singleton.getXPathValue()
}).then((query) => {
if (query === undefined) return;
@ -17,6 +18,8 @@ export function evaluateXPath(editor: TextEditor, edit: TextEditorEdit): void {
let xml = editor.document.getText();
let doc = new dom().parseFromString(xml);
Singleton.setXPathValue(query);
try {
var nodes = xpath.select(query, doc);
}
@ -43,3 +46,21 @@ export function evaluateXPath(editor: TextEditor, edit: TextEditorEdit): void {
resultChannel.show(ViewColumn.Three);
});
}
namespace Singleton {
class XPathContext
{
static _lastXPathValue:string = '';
}
export function getXPathValue():string
{
return XPathContext._lastXPathValue;
}
export function setXPathValue(val:string):void
{
XPathContext._lastXPathValue = val;
}
}