-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed the `git diff` parser issue. Toggle Widget with alt+h or via view menu The list gets lazy loaded Signed-off-by: Jan Bicker <jan.bicker@typefox.io>
- Loading branch information
Showing
17 changed files
with
915 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
packages/git/src/browser/history/git-history-contribution.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/* | ||
* Copyright (C) 2018 TypeFox and others. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
*/ | ||
|
||
import { MenuModelRegistry, CommandRegistry, Command, SelectionService } from "@theia/core"; | ||
import { AbstractViewContribution } from "@theia/core/lib/browser"; | ||
import { injectable, inject } from "inversify"; | ||
import { NAVIGATOR_CONTEXT_MENU } from "@theia/navigator/lib/browser/navigator-menu"; | ||
import { UriCommandHandler, FileSystemCommandHandler } from "@theia/workspace/lib/browser/workspace-commands"; | ||
import { GitHistoryWidget } from './git-history-widget'; | ||
import { Git } from "../../common"; | ||
|
||
export namespace GitHistoryCommands { | ||
export const OPEN_FILE_HISTORY: Command = { | ||
id: 'git-history:open-file-history', | ||
label: 'Git History' | ||
}; | ||
export const OPEN_BRANCH_HISTORY: Command = { | ||
id: 'git-history:open-branch-history' | ||
}; | ||
} | ||
|
||
export const GIT_HISTORY = 'git-history'; | ||
export const GIT_HISTORY_MAX_COUNT = 100; | ||
@injectable() | ||
export class GitHistoryContribution extends AbstractViewContribution<GitHistoryWidget> { | ||
|
||
constructor( | ||
@inject(SelectionService) protected readonly selectionService: SelectionService) { | ||
super({ | ||
widgetId: GIT_HISTORY, | ||
widgetName: 'Git History', | ||
defaultWidgetOptions: { | ||
area: 'left', | ||
rank: 400 | ||
}, | ||
toggleCommandId: GitHistoryCommands.OPEN_BRANCH_HISTORY.id, | ||
toggleKeybinding: 'alt+h' | ||
}); | ||
} | ||
|
||
registerMenus(menus: MenuModelRegistry): void { | ||
menus.registerMenuAction([...NAVIGATOR_CONTEXT_MENU, '5_history'], { | ||
commandId: GitHistoryCommands.OPEN_FILE_HISTORY.id | ||
}); | ||
|
||
super.registerMenus(menus); | ||
} | ||
|
||
registerCommands(commands: CommandRegistry): void { | ||
commands.registerCommand(GitHistoryCommands.OPEN_FILE_HISTORY, this.newFileHandler({ | ||
execute: async uri => { | ||
const options: Git.Options.Log = { | ||
uri: uri.toString(), | ||
maxCount: GIT_HISTORY_MAX_COUNT, | ||
shortSha: true | ||
}; | ||
this.showWidget(options); | ||
} | ||
})); | ||
commands.registerCommand(GitHistoryCommands.OPEN_BRANCH_HISTORY, { | ||
execute: () => { | ||
this.showWidget({ | ||
maxCount: GIT_HISTORY_MAX_COUNT, | ||
shortSha: true | ||
}); | ||
} | ||
}); | ||
} | ||
|
||
async showWidget(options?: Git.Options.Log) { | ||
const widget = await this.widget; | ||
await widget.setContent(options); | ||
this.openView({ | ||
toggle: true, | ||
activate: true | ||
}); | ||
} | ||
|
||
protected newFileHandler(handler: UriCommandHandler): FileSystemCommandHandler { | ||
return new FileSystemCommandHandler(this.selectionService, handler); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
packages/git/src/browser/history/git-history-frontend-module.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright (C) 2018 TypeFox and others. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
*/ | ||
|
||
import { GitHistoryContribution, GIT_HISTORY } from "./git-history-contribution"; | ||
import { interfaces } from "inversify"; | ||
import { CommandContribution, MenuContribution } from "@theia/core"; | ||
import { KeybindingContribution } from "@theia/core/lib/browser/keybinding"; | ||
import { WidgetFactory } from "@theia/core/lib/browser"; | ||
import { GitHistoryWidget } from "./git-history-widget"; | ||
|
||
import '../../../src/browser/style/history.css'; | ||
|
||
export function bindGitHistoryModule(bind: interfaces.Bind) { | ||
|
||
bind(GitHistoryWidget).toSelf(); | ||
bind(WidgetFactory).toDynamicValue(ctx => ({ | ||
id: GIT_HISTORY, | ||
createWidget: () => ctx.container.get<GitHistoryWidget>(GitHistoryWidget) | ||
})); | ||
|
||
bind(GitHistoryContribution).toSelf().inSingletonScope(); | ||
for (const identifier of [CommandContribution, MenuContribution, KeybindingContribution]) { | ||
bind(identifier).toDynamicValue(ctx => | ||
ctx.container.get(GitHistoryContribution) | ||
).inSingletonScope(); | ||
} | ||
|
||
} |
Oops, something went wrong.