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';
 | 
			
		||||
 | 
			
		||||
import { window, TextEditor, TextEditorEdit, OutputChannel, ViewColumn } from 'vscode';
 | 
			
		||||
import { window, TextEditor, TextEditorEdit, OutputChannel, ViewColumn, workspace } from 'vscode';
 | 
			
		||||
 | 
			
		||||
let xpath = require('xpath');
 | 
			
		||||
let dom = require('xmldom').DOMParser;
 | 
			
		||||
let resultChannel: OutputChannel = null;
 | 
			
		||||
 | 
			
		||||
export function evaluateXPath(editor: TextEditor, edit: TextEditorEdit): void {
 | 
			
		||||
    let isPersistant = workspace.getConfiguration().has('xmlTools.PersistXPathQuery') && workspace.getConfiguration('xmlTools').get<boolean>('PersistXPathQuery') === true	    
 | 
			
		||||
    
 | 
			
		||||
    window.showInputBox({
 | 
			
		||||
		placeHolder: 'XPath Query',
 | 
			
		||||
		prompt: 'Please enter an XPath query to evaluate.',
 | 
			
		||||
		value: Singleton.getXPathValue()
 | 
			
		||||
		value: isPersistant ? Singleton.getXPathValue() : ''
 | 
			
		||||
		
 | 
			
		||||
	}).then((query) => {
 | 
			
		||||
		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');
 | 
			
		||||
		resultChannel.clear();
 | 
			
		||||
				
 | 
			
		||||
		resultChannel.appendLine('Last query: ' + query + '\n');
 | 
			
		||||
		
 | 
			
		||||
		nodes.forEach((node) => {
 | 
			
		||||
			resultChannel.appendLine(`${node.localName}: ${node.firstChild.data}`);
 | 
			
		||||
		});
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue