Skip to content

Commit

Permalink
feat: auto keep temp editor
Browse files Browse the repository at this point in the history
  • Loading branch information
tjx666 committed Jul 8, 2023
1 parent c85c4b3 commit 2c21cbd
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@
"href": "https://github.com/tjx666/power-edit"
}
],
"activationEvents": [],
"activationEvents": [
"onStartupFinished"
],
"contributes": {
"commands": [
{
Expand Down
2 changes: 2 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import vscode from 'vscode';

export function activate(context: vscode.ExtensionContext) {
import('./features/autoKeepTempEditor').then((mod) => mod.autoKeepTempEditor(context));

const { commands } = vscode;

const registerTextEditorCommand = (
Expand Down
16 changes: 16 additions & 0 deletions src/features/autoKeepTempEditor.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import type { ExtensionContext } from 'vscode';
import vscode from 'vscode';

export function autoKeepTempEditor(context: ExtensionContext) {
vscode.workspace.onDidOpenTextDocument(
async (document) => {
const { uri } = document;
const isGitErrorEditor = uri.scheme === 'git-output' && /\/git-error-/.test(uri.fsPath);
if (isGitErrorEditor) {
await vscode.commands.executeCommand('workbench.action.keepEditor');
}
},
null,
context.subscriptions,
);
}

0 comments on commit 2c21cbd

Please sign in to comment.