Skip to content

Commit

Permalink
Update active editor file uri details in workspace state for images (#…
Browse files Browse the repository at this point in the history
…736)

* Media file edit using luna paint extension for V1 and V2 data model

* Change event name for active editor file reload
  • Loading branch information
tyaginidhi authored Oct 11, 2023
1 parent 94e295c commit 9639a84
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/web/client/WebExtensionContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ class WebExtensionContext implements IWebExtensionContext {
this._isContextSet = true;
}

public async setVscodeWorkspaceState(workspaceState: vscode.Memento) {
public setVscodeWorkspaceState(workspaceState: vscode.Memento) {
try {
workspaceState.keys().forEach((key) => {
const entityInfo = workspaceState.get(key) as IEntityInfo;
Expand Down
36 changes: 22 additions & 14 deletions src/web/client/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export function activate(context: vscode.ExtensionContext): void {
vscodeExtAppInsightsResourceProvider.GetAppInsightsResourceForDataBoundary(
dataBoundary
);
WebExtensionContext.setVscodeWorkspaceState(context.workspaceState);
WebExtensionContext.telemetry.setTelemetryReporter(
context.extension.id,
context.extension.packageJSON.version,
Expand Down Expand Up @@ -104,7 +105,6 @@ export function activate(context: vscode.ExtensionContext): void {
queryParamsMap,
context.extensionUri
);
WebExtensionContext.setVscodeWorkspaceState(context.workspaceState);
WebExtensionContext.telemetry.sendExtensionInitPathParametersTelemetry(
appName,
entity,
Expand Down Expand Up @@ -226,20 +226,28 @@ export function processWalkthroughFirstRunExperience(context: vscode.ExtensionCo

export function processWorkspaceStateChanges(context: vscode.ExtensionContext) {
context.subscriptions.push(
vscode.workspace.onDidOpenTextDocument((textDocument) => {
const entityInfo: IEntityInfo = {
entityId: getFileEntityId(textDocument.uri.fsPath),
entityName: getFileEntityName(textDocument.uri.fsPath)
};
context.workspaceState.update(textDocument.uri.fsPath, entityInfo);
WebExtensionContext.updateVscodeWorkspaceState(textDocument.uri.fsPath, entityInfo);
})
);
vscode.window.tabGroups.onDidChangeTabs((event) => {
event.opened.concat(event.changed).forEach(tab => {
if (tab.input instanceof vscode.TabInputCustom || tab.input instanceof vscode.TabInputText) {
const document = tab.input;
const entityInfo: IEntityInfo = {
entityId: getFileEntityId(document.uri.fsPath),
entityName: getFileEntityName(document.uri.fsPath)
};
if (entityInfo.entityId && entityInfo.entityName) {
context.workspaceState.update(document.uri.fsPath, entityInfo);
WebExtensionContext.updateVscodeWorkspaceState(document.uri.fsPath, entityInfo);
}
}
});

context.subscriptions.push(
vscode.workspace.onDidCloseTextDocument((textDocument) => {
context.workspaceState.update(textDocument.uri.fsPath, undefined);
WebExtensionContext.updateVscodeWorkspaceState(textDocument.uri.fsPath, undefined);
event.closed.forEach(tab => {
if (tab.input instanceof vscode.TabInputCustom || tab.input instanceof vscode.TabInputText) {
const document = tab.input;
context.workspaceState.update(document.uri.fsPath, undefined);
WebExtensionContext.updateVscodeWorkspaceState(document.uri.fsPath, undefined);
}
});
})
);
}
Expand Down

0 comments on commit 9639a84

Please sign in to comment.