mirror of
https://github.com/kahole/edamagit.git
synced 2024-09-11 07:15:31 +03:00
implements apply-at-point for stashes
This commit is contained in:
parent
680427ff9d
commit
b7054f66ea
13
package.json
13
package.json
@ -24,6 +24,10 @@
|
||||
"command": "extension.magit-visit-at-point",
|
||||
"title": "Magit Visit-at-point"
|
||||
},
|
||||
{
|
||||
"command": "extension.magit-apply-at-point",
|
||||
"title": "Magit Apply-at-point"
|
||||
},
|
||||
{
|
||||
"command": "extension.magit-commit",
|
||||
"title": "Magit Commit"
|
||||
@ -71,6 +75,10 @@
|
||||
"command": "extension.magit-visit-at-point",
|
||||
"when": "editorLangId == magit"
|
||||
},
|
||||
{
|
||||
"command": "extension.magit-apply-at-point",
|
||||
"when": "editorLangId == magit"
|
||||
},
|
||||
{
|
||||
"command": "extension.magit-stage",
|
||||
"when": "editorLangId == magit"
|
||||
@ -146,6 +154,11 @@
|
||||
"key": "enter",
|
||||
"when": "editorTextFocus && editorLangId == magit"
|
||||
},
|
||||
{
|
||||
"command": "extension.magit-apply-at-point",
|
||||
"key": "a",
|
||||
"when": "editorTextFocus && editorLangId == magit"
|
||||
},
|
||||
{
|
||||
"command": "extension.magit-commit",
|
||||
"key": "c",
|
||||
|
@ -1,9 +1,21 @@
|
||||
import { window } from 'vscode';
|
||||
import { MagitRepository } from '../models/magitRepository';
|
||||
import { CommitItemView } from '../views/commits/commitSectionView';
|
||||
import { DocumentView } from '../views/general/documentView';
|
||||
import { gitRun } from '../utils/gitRawRunner';
|
||||
import { StashItemView } from '../views/stashes/stashSectionView';
|
||||
|
||||
export async function magitApplyEntityAtPoint(repository: MagitRepository, currentView: DocumentView): Promise<any> {
|
||||
|
||||
// a - Apply at point
|
||||
const selectedView = currentView.click(window.activeTextEditor!.selection.active);
|
||||
|
||||
// to quickly apply a stash or something else (commit?)
|
||||
if (selectedView instanceof CommitItemView) {
|
||||
|
||||
} else if (selectedView instanceof StashItemView) {
|
||||
|
||||
// Apply stash
|
||||
// git stash apply --index ${stash.index}
|
||||
const stash = (selectedView as StashItemView).stash;
|
||||
|
||||
const args = ['stash', 'apply', '--index', stash.index.toString()];
|
||||
return gitRun(repository, args);
|
||||
}
|
||||
}
|
@ -18,6 +18,7 @@ import { fetching } from './commands/fetchingCommands';
|
||||
import { pulling } from './commands/pullingCommands';
|
||||
import { stashing } from './commands/stashingCommands';
|
||||
import { DocumentView } from './views/general/documentView';
|
||||
import { magitApplyEntityAtPoint } from './commands/applyCommands';
|
||||
|
||||
export const magitRepositories: Map<string, MagitRepository> = new Map<string, MagitRepository>();
|
||||
export const views: Map<string, DocumentView> = new Map<string, DocumentView>();
|
||||
@ -56,6 +57,7 @@ export function activate(context: ExtensionContext) {
|
||||
context.subscriptions.push(commands.registerTextEditorCommand('extension.magit-refresh', CommandPrimer.primeRepoAndView(magitRefresh)));
|
||||
context.subscriptions.push(commands.registerTextEditorCommand('extension.magit-commit', CommandPrimer.primeRepoAndView(magitCommit)));
|
||||
context.subscriptions.push(commands.registerTextEditorCommand('extension.magit-visit-at-point', CommandPrimer.primeRepoAndView(magitVisitAtPoint, false)));
|
||||
context.subscriptions.push(commands.registerTextEditorCommand('extension.magit-apply-at-point', CommandPrimer.primeRepoAndView(magitApplyEntityAtPoint)));
|
||||
context.subscriptions.push(commands.registerCommand('extension.magit-help', magitHelp));
|
||||
context.subscriptions.push(commands.registerTextEditorCommand('extension.magit-pulling', CommandPrimer.primeRepoAndView(pulling)));
|
||||
context.subscriptions.push(commands.registerTextEditorCommand('extension.magit-pushing', CommandPrimer.primeRepoAndView(pushing)));
|
||||
|
Loading…
Reference in New Issue
Block a user