Adding to #6 - user setting to persist the last query
This commit is contained in:
		
							parent
							
								
									f3ea33a522
								
							
						
					
					
						commit
						b668ab49c3
					
				
					 1 changed files with 6 additions and 6 deletions
				
			
		| 
						 | 
					@ -1,16 +1,18 @@
 | 
				
			||||||
'use strict';
 | 
					'use strict';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import { window, TextEditor, TextEditorEdit, OutputChannel, ViewColumn } from 'vscode';
 | 
					import { window, TextEditor, TextEditorEdit, OutputChannel, ViewColumn, workspace } from 'vscode';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
let xpath = require('xpath');
 | 
					let xpath = require('xpath');
 | 
				
			||||||
let dom = require('xmldom').DOMParser;
 | 
					let dom = require('xmldom').DOMParser;
 | 
				
			||||||
let resultChannel: OutputChannel = null;
 | 
					let resultChannel: OutputChannel = null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export function evaluateXPath(editor: TextEditor, edit: TextEditorEdit): void {
 | 
					export function evaluateXPath(editor: TextEditor, edit: TextEditorEdit): void {
 | 
				
			||||||
	window.showInputBox({
 | 
					    let isPersistant = workspace.getConfiguration().has('xmlTools.PersistXPathQuery') && workspace.getConfiguration('xmlTools').get<boolean>('PersistXPathQuery') === true	    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    window.showInputBox({
 | 
				
			||||||
		placeHolder: 'XPath Query',
 | 
							placeHolder: 'XPath Query',
 | 
				
			||||||
		prompt: 'Please enter an XPath query to evaluate.',
 | 
							prompt: 'Please enter an XPath query to evaluate.',
 | 
				
			||||||
		value: Singleton.getXPathValue()
 | 
							value: isPersistant ? Singleton.getXPathValue() : ''
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
	}).then((query) => {
 | 
						}).then((query) => {
 | 
				
			||||||
		if (query === undefined) return;
 | 
							if (query === undefined) return;
 | 
				
			||||||
| 
						 | 
					@ -37,8 +39,6 @@ export function evaluateXPath(editor: TextEditor, edit: TextEditorEdit): void {
 | 
				
			||||||
		if (resultChannel === null) resultChannel = window.createOutputChannel('XPath Evaluation Results');
 | 
							if (resultChannel === null) resultChannel = window.createOutputChannel('XPath Evaluation Results');
 | 
				
			||||||
		resultChannel.clear();
 | 
							resultChannel.clear();
 | 
				
			||||||
				
 | 
									
 | 
				
			||||||
		resultChannel.appendLine('Last query: ' + query + '\n');
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		nodes.forEach((node) => {
 | 
							nodes.forEach((node) => {
 | 
				
			||||||
			resultChannel.appendLine(`${node.localName}: ${node.firstChild.data}`);
 | 
								resultChannel.appendLine(`${node.localName}: ${node.firstChild.data}`);
 | 
				
			||||||
		});
 | 
							});
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue