Commit 13005750 authored by Timon Stampfli's avatar Timon Stampfli

show sample on hover over sample in sampleview

parent 103a282a
Pipeline #5698 passed with stages
in 1 minute
......@@ -2,6 +2,7 @@ import * as vscode from "vscode";
import { Store } from "./store";
import * as path from "path";
import { toSortedKeys } from "./util";
import { EOL } from "os";
export class SamplesTreeViewProvider
implements vscode.TreeDataProvider<string> {
......@@ -24,13 +25,47 @@ export class SamplesTreeViewProvider
sample,
vscode.TreeItemCollapsibleState.None
);
let sampleData = this.store.samples.get(sample);
if (sampleData === undefined) {
vscode.window.showErrorMessage(
"Internal error when showing the sample tree"
);
throw new Error("Internal error when showing the sample tree");
}
let input = "";
let output = "";
sampleData.data.forEach(entry => {
if (entry.key === "input") {
input = entry.value;
}
if (entry.key === "output") {
output = entry.value;
}
});
let inplines = input.split(EOL);
let outlines = output.split(EOL);
let tooltip =
"*Input*: \n" +
(inplines.length < 12
? input
: inplines.slice(0, 12).join("\n") +
`\n... ${inplines.length - 12} more lines`) +
"*Output*: \n" +
(outlines.length < 12
? output
: outlines.slice(0, 12).join("\n") +
`\n... ${outlines.length - 12} more lines`);
item.contextValue = "sample";
item.command = {
command: "soicode.openSample",
title: "Open Sample",
arguments: [sample],
tooltip: "Open Sample"
}; // todo register as command
arguments: [sample]
};
item.tooltip = tooltip;
// switch(this.state.samples.get){
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment