Skip to content

Commit f8741a3

Browse files
committed
Update filebrowser.js
1 parent 7b14820 commit f8741a3

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

filebrowser.js

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2230,14 +2230,40 @@ function createNewFileInHTML() {
22302230
});
22312231

22322232

2233-
async function pushNewFileInHTML() {
2233+
async function pushNewFileInHTML(event) {
22342234

22352235
if (fileEl.classList.contains('focused')) {
22362236

22372237
const dialogResp = await checkPushDialogs();
22382238

22392239
if (dialogResp === 'return') return;
22402240

2241+
2242+
let commitMessage = 'Create ' + fileName;
2243+
2244+
// if ctrl/cmd/shift-clicked on push button
2245+
if (!isMobile && (isKeyEventMeta(event) || event.shiftKey)) {
2246+
2247+
// get selected branch
2248+
let selBranch = treeLoc[1].split(':')[1];
2249+
2250+
// open push screen
2251+
commitMessage = prompt('Push \''+ fileEl.innerText + (selBranch ? '\' to branch \'' + selBranch + '\'?' : '\'?'),
2252+
'Type commit message...');
2253+
2254+
// if canceled push, return
2255+
if (!commitMessage) return;
2256+
2257+
// if not specified message
2258+
if (commitMessage === 'Type a commit message...') {
2259+
2260+
// show default message
2261+
commitMessage = 'Create ' + fileName;
2262+
2263+
}
2264+
2265+
}
2266+
22412267

22422268
// play push animation
22432269
playPushAnimation(fileEl.querySelector('.push-wrapper'));
@@ -2375,7 +2401,6 @@ function createNewFileInHTML() {
23752401

23762402

23772403
// create commit
2378-
const commitMessage = 'Create ' + fileName;
23792404

23802405
const commitFile = {
23812406
name: fileName,
@@ -2949,7 +2974,7 @@ function setupEditor() {
29492974

29502975
}
29512976

2952-
// show beautify message on Ctrl/Cmd + B/D
2977+
// show beautify message on Ctrl/Cmd + B/P
29532978
if (((e.key === 'b' || e.keyCode === 66)
29542979
|| (e.key === 'p' || e.keyCode === 80))
29552980
&& isKeyEventMeta(e)) {

0 commit comments

Comments
 (0)