diff --git a/CHANGELOG.md b/CHANGELOG.md index 93b2f12..060c924 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,12 @@ All notable changes to the "vscode-vespa" extension will be documented in this file. + +## [1.0.1] + +- Minor bugfix for zipkin +- Fix keyboard shortcuts not clashing with vscode default shortcuts. + ## [1.0.0] - Initial release - diff --git a/README.md b/README.md index 056c00a..83c5063 100644 --- a/README.md +++ b/README.md @@ -71,8 +71,4 @@ This is not enabled as the features it gives, at the moment, is limited. ## Release Notes -### 1.0.0 - -Initial release - ---- +Please read the [CHANGELOG](CHANGELOG.md) \ No newline at end of file diff --git a/client/package.json b/client/package.json index e291873..175a57b 100644 --- a/client/package.json +++ b/client/package.json @@ -3,7 +3,7 @@ "description": "VSCode part of a language server", "author": "Matti Pehrs", "license": "MIT", - "version": "1.0.0", + "version": "1.0.1", "publisher": "pehrs.com", "engines": { "vscode": "^1.75.0" diff --git a/client/src/extension.ts b/client/src/extension.ts index 7a4e628..4094b0e 100644 --- a/client/src/extension.ts +++ b/client/src/extension.ts @@ -34,6 +34,8 @@ export function activate(context: ExtensionContext) { registerRunQueryCommand(context); registerFormatterCommand(context); + registerYqlFormatter(context); + // NOT Needed yet as we are not saving the result state anywhere // Results panel view // if (vscode.window.registerWebviewPanelSerializer) { @@ -231,11 +233,13 @@ function registerRunQueryCommand(context: ExtensionContext) { const editor = vscode.window.activeTextEditor; + outputChannel.appendLine(`file: ${editor.document.fileName}`); + const workbenchConfig = vscode.workspace.getConfiguration('vespaYql'); const queryEndpoint: string = workbenchConfig.get('queryEndpoint'); const queryTimeout: string = workbenchConfig.get('queryTimeout'); - if (editor) { + if (editor && editor.document.fileName.endsWith(".yql")) { const document = editor.document; // Get the document text const yql = document.getText(); @@ -247,38 +251,60 @@ function registerRunQueryCommand(context: ExtensionContext) { } -function registerFormatterCommand(context: ExtensionContext) { - const runYqlCommand = vscode.commands.registerCommand('vscode-vespa.format', () => { +function registerYqlFormatter(context: ExtensionContext) { + vscode.languages.registerDocumentFormattingEditProvider('yql', { + provideDocumentFormattingEdits(document: vscode.TextDocument): vscode.TextEdit[] { - const editor = vscode.window.activeTextEditor; + formatYql(); + + // const firstLine = document.lineAt(0); + // if (firstLine.text !== '42') { + // return [vscode.TextEdit.insert(firstLine.range.start, '42\n')]; + // } + return []; + } + }); +} - if (editor) { - try { - const document = editor.document; - // Get the document text - const yql = document.getText(); - - const jsonObj = JSON.parse(yql); - const newYql = JSON.stringify(jsonObj, null, 2); - - const start = new vscode.Position(0, 0); - const lastLine = document.lineCount - 1; - const end = new vscode.Position(lastLine, document.lineAt(lastLine).text.length); - const allText = new vscode.Range(start, end); - - const edit = new vscode.WorkspaceEdit(); - edit.replace(document.uri, allText, newYql); - // edit.insert(document.uri, firstLine.range.start, '42\n'); - - return vscode.workspace.applyEdit(edit); - } catch (e) { - if (typeof e === "string") { - showError(e); - } else if (e instanceof Error) { - showError(e.message); - } + +function formatYql() { + const editor = vscode.window.activeTextEditor; + + outputChannel.appendLine(`format ${editor.document.fileName}`); + + if (editor && editor.document.fileName.endsWith(".yql")) { + try { + const document = editor.document; + // Get the document text + const yql = document.getText(); + + const jsonObj = JSON.parse(yql); + const newYql = JSON.stringify(jsonObj, null, 2); + + const start = new vscode.Position(0, 0); + const lastLine = document.lineCount - 1; + const end = new vscode.Position(lastLine, document.lineAt(lastLine).text.length); + const allText = new vscode.Range(start, end); + + const edit = new vscode.WorkspaceEdit(); + edit.replace(document.uri, allText, newYql); + // edit.insert(document.uri, firstLine.range.start, '42\n'); + + return vscode.workspace.applyEdit(edit); + } catch (e) { + if (typeof e === "string") { + showError(e); + } else if (e instanceof Error) { + showError(e.message); } } + } +} + +function registerFormatterCommand(context: ExtensionContext) { + const runYqlCommand = vscode.commands.registerCommand('vscode-vespa.format', () => { + + formatYql(); }); context.subscriptions.push(runYqlCommand); } @@ -709,8 +735,8 @@ class YqlResultsPanel { // TRACE if (this.zipkinLink !== undefined) { result += `
`; - result += `