Make users save new file (#110330)

This commit is contained in:
Christof Marti 2020-11-17 13:28:46 +01:00
parent 442b1d1b61
commit 9c4c195980
4 changed files with 21 additions and 3 deletions

View file

@ -18,7 +18,8 @@ export default () => `
<div class="section start">
<h2 class="caption">${escape(localize('welcomePage.start', "Start"))}</h2>
<ul>
<li><a href="command:workbench.action.files.newUntitledFile">${escape(localize('welcomePage.newFile', "New file"))}</a></li>
<li class="empty-window-only"><a href="command:workbench.action.files.newUntitledFile">${escape(localize('welcomePage.newFile', "New file"))}</a></li>
<li class="none-empty-window-only"><a href="command:explorer.newFile">${escape(localize('welcomePage.newFile', "New file"))}</a></li>
<li class="mac-only"><a href="command:workbench.action.files.openFileFolder">${escape(localize('welcomePage.openFolder', "Open folder..."))}</a> or <a href="command:git.clone">${escape(localize('welcomePage.gitClone', "clone repository..."))}</a></li>
<li class="windows-only linux-only"><a href="command:workbench.action.files.openFolder">${escape(localize('welcomePage.openFolder', "Open folder..."))}</a> or <a href="command:git.clone">${escape(localize('welcomePage.gitClone', "clone repository..."))}</a></li>
</ul>

View file

@ -246,3 +246,13 @@
.monaco-workbench.linux .part.editor > .content .welcomePage li.linux-only {
display: list-item;
}
.monaco-workbench .part.editor > .content .welcomePage.empty-window .none-empty-window-only {
display: none;
}
.monaco-workbench .part.editor > .content .welcomePage .empty-window-only {
display: none;
}
.monaco-workbench .part.editor > .content .welcomePage.empty-window .empty-window-only {
display: initial;
}

View file

@ -331,12 +331,14 @@ class WelcomePage extends Disposable {
prodName.textContent = this.productService.nameLong;
}
const pageElement = container.querySelector('.welcomePage') as HTMLElement;
pageElement.classList.add(this.contextService.getWorkbenchState() === WorkbenchState.EMPTY ? 'empty-window' : 'none-empty-window');
recentlyOpened.then(({ workspaces }) => {
// Filter out the current workspace
workspaces = workspaces.filter(recent => !this.contextService.isCurrentWorkspace(isRecentWorkspace(recent) ? recent.workspace : recent.folderUri));
if (!workspaces.length) {
const recent = container.querySelector('.welcomePage') as HTMLElement;
recent.classList.add('emptyRecent');
pageElement.classList.add('emptyRecent');
return;
}
const ul = container.querySelector('.recent ul');

View file

@ -189,6 +189,11 @@ export class WalkThroughPart extends EditorPane {
this.notificationService.info(localize('walkThrough.gitNotFound', "It looks like Git is not installed on your system."));
return;
}
if (uri.scheme === 'command' && uri.path === 'workbench.action.files.newUntitledFile') {
this.openerService.open(this.addFrom(uri))
.then(() => this.openerService.open(this.addFrom(URI.parse('command:workbench.action.files.save'))));
return;
}
this.openerService.open(this.addFrom(uri));
}