Skip to content

Commit 216b0f9

Browse files
committed
Add Show Diff button to file selection quick pick for viewing changes before commit
1 parent 2039058 commit 216b0f9

2 files changed

Lines changed: 30 additions & 1 deletion

File tree

‎apps/editor/src/i18n/translations/commands/generate-commit-message.ts‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,5 +125,23 @@ export const generate_commit_message = {
125125
cs: 'Vyberte soubory k commitnutí',
126126
hu: 'Válassza ki a commitolandó fájlokat',
127127
bg: 'Изберете файлове за commit'
128+
},
129+
'command.commit-message.show-diff': {
130+
en: 'Show Diff',
131+
pl: 'Pokaż zmiany',
132+
'zh-cn': '显示差异',
133+
ja: '変更を表示',
134+
'zh-tw': '顯示差異',
135+
de: 'Änderungen anzeigen',
136+
es: 'Mostrar cambios',
137+
fr: 'Afficher les modifications',
138+
'pt-br': 'Mostrar alterações',
139+
ru: 'Показать изменения',
140+
ko: '차이 보기',
141+
it: 'Mostra differenze',
142+
tr: 'Değişiklikleri Göster',
143+
cs: 'Zobrazit změny',
144+
hu: 'Eltérések megjelenítése',
145+
bg: 'Покажи разликите'
128146
}
129147
} as const

‎apps/editor/src/utils/git-repository-utils.ts‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,12 @@ export const prepare_staged_changes = async (
184184
picked: true,
185185
fsPath: change.uri.fsPath,
186186
buttons: [
187+
{
188+
iconPath: new vscode.ThemeIcon(
189+
'git-pull-request-go-to-changes'
190+
),
191+
tooltip: t('command.commit-message.show-diff')
192+
},
187193
{
188194
iconPath: new vscode.ThemeIcon('go-to-file'),
189195
tooltip: t('common.go-to-file')
@@ -215,10 +221,15 @@ export const prepare_staged_changes = async (
215221
}
216222
})
217223

218-
quick_pick.onDidTriggerItemButton((event) => {
224+
quick_pick.onDidTriggerItemButton(async (event) => {
219225
if (event.button.tooltip == t('common.go-to-file')) {
220226
const uri = vscode.Uri.file(event.item.fsPath)
221227
vscode.window.showTextDocument(uri, { preview: true })
228+
} else if (
229+
event.button.tooltip == t('command.commit-message.show-diff')
230+
) {
231+
const uri = vscode.Uri.file(event.item.fsPath)
232+
await vscode.commands.executeCommand('git.openChange', uri)
222233
}
223234
})
224235

0 commit comments

Comments
 (0)