Skip to content

Commit

Permalink
fix refreshing
Browse files Browse the repository at this point in the history
  • Loading branch information
pvh committed Nov 30, 2018
1 parent 888d023 commit 2ee7de0
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 16 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export function activate(context: vscode.ExtensionContext) {
console.log("HypermergeFS activated");
const hypermergeWrapper = new HypermergeWrapper();

const output = vscode.window.createOutputChannel("Hypermerge")
const output = vscode.window.createOutputChannel("Hypermerge");

const hypermergeFs = new HypermergeFS(hypermergeWrapper);
context.subscriptions.push(
Expand All @@ -26,11 +26,12 @@ export function activate(context: vscode.ExtensionContext) {
(vscode.languages as any).setTextDocumentLanguage(document, "json");
}
}
}));
})
);

context.subscriptions.push(
vscode.window.registerUriHandler(new HypermergeUriHandler(output))
)
(vscode.window as any).registerUriHandler(new HypermergeUriHandler(output))
);

// self-registers
new HypermergeExplorer(context, hypermergeWrapper);
Expand Down
25 changes: 14 additions & 11 deletions src/treeview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ export class HypermergeTreeDataProvider
implements vscode.TreeDataProvider<HypermergeNodeKey> {
private _onDidChangeTreeData: vscode.EventEmitter<
HypermergeNodeKey | undefined
> = new vscode.EventEmitter<HypermergeNodeKey | undefined>();
> = new vscode.EventEmitter<HypermergeNodeKey | undefined>();
readonly onDidChangeTreeData: vscode.Event<
HypermergeNodeKey | undefined
> = this._onDidChangeTreeData.event;
> = this._onDidChangeTreeData.event;

constructor(private readonly hypermergeWrapper: HypermergeWrapper) {
this.hypermergeWrapper = hypermergeWrapper;
this.hypermergeWrapper.addListener("update", uri => {
this._onDidChangeTreeData.fire(uri);
this.hypermergeWrapper.addListener("update", (uri: vscode.Uri) => {
this._onDidChangeTreeData.fire(uri.toString());
});
}

Expand Down Expand Up @@ -72,7 +72,7 @@ export class HypermergeTreeDataProvider
}

public addRoot(uriString: string) {
if (this.roots().has(uriString)) return
if (this.roots().has(uriString)) return;

const inspectRoots = vscode.workspace
.getConfiguration("hypermergefs")
Expand Down Expand Up @@ -190,13 +190,16 @@ export class HypermergeExplorer {
treeDataProvider.refresh()
);

vscode.commands.registerCommand("hypermergeExplorer.open", (uriString: string) => {
if (!this.validateURL(uriString)) {
treeDataProvider.addRoot(uriString);
treeDataProvider.refresh();
vscode.workspace.openTextDocument(vscode.Uri.parse(uriString))
vscode.commands.registerCommand(
"hypermergeExplorer.open",
(uriString: string) => {
if (!this.validateURL(uriString)) {
treeDataProvider.addRoot(uriString);
treeDataProvider.refresh();
vscode.workspace.openTextDocument(vscode.Uri.parse(uriString));
}
}
});
);

context.subscriptions.push(
vscode.workspace.onDidChangeConfiguration(e => {
Expand Down

0 comments on commit 2ee7de0

Please sign in to comment.