-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changed Query Display to Split Pane, query box now remembers last com…
…mand
- Loading branch information
Avin M
committed
May 27, 2018
1 parent
3b2247f
commit f060da0
Showing
4 changed files
with
41 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,46 @@ | ||
"use strict"; | ||
|
||
import * as vscode from "vscode"; | ||
import { Uri, ViewColumn, Selection, Position } from "vscode"; | ||
import * as fs from "fs"; | ||
import * as os from "os"; | ||
import * as path from "path"; | ||
import { ResultViewer } from "./resultViewer"; | ||
import JMESPathQueryCommandHandler from "./../command/jmespathQueryCommandHandler"; | ||
|
||
export default class OutputChannelResultViewer implements ResultViewer { | ||
private outputChannel: vscode.OutputChannel; | ||
private indentString: string; | ||
private resultsFilePath: string; | ||
private resultsDoc: vscode.TextDocument; | ||
|
||
constructor(channelName: string, indent: string = " ") { | ||
this.outputChannel = vscode.window.createOutputChannel(channelName); | ||
this.indentString = indent; | ||
this.outputChannel.show(); | ||
this.resultsFilePath = path.join(os.tmpdir(), "Query Results.json"); | ||
} | ||
|
||
public viewResult(queryResult: any) { | ||
this.outputChannel.clear(); | ||
this.outputChannel.appendLine(JSON.stringify(queryResult, null, this.indentString)); | ||
this.outputChannel.show(); | ||
fs.writeFileSync(this.resultsFilePath, ""); | ||
const resultsFileUri = Uri.file(this.resultsFilePath); | ||
const resultsFileUri2 = Uri.file(path.join(os.tmpdir(), "Query Results2.json")); | ||
if (this.resultsDoc) | ||
this.resultsDoc.save(); | ||
fs.writeFileSync(this.resultsFilePath, JSON.stringify(queryResult, null, this.indentString)); | ||
vscode.workspace.openTextDocument(resultsFileUri).then(doc => { | ||
this.resultsDoc = doc; | ||
vscode.window.showTextDocument(doc, getViewColumn(), true); | ||
} | ||
); | ||
} | ||
|
||
public dispose() { | ||
this.outputChannel.dispose(); | ||
fs.unlink(this.resultsFilePath); | ||
} | ||
} | ||
|
||
function getViewColumn(): ViewColumn { | ||
const activeEditor = vscode.window.activeTextEditor; | ||
if (!activeEditor) { | ||
return ViewColumn.One; | ||
} | ||
return activeEditor.viewColumn + 1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters