Merge from vscode ad407028575a77ea387eb7cc219b323dc017b686

This commit is contained in:
ADS Merger
2020-08-22 06:06:52 +00:00
committed by Anthony Dresser
parent 404260b8a0
commit 4ad73d381c
480 changed files with 14360 additions and 14122 deletions

View File

@@ -30,7 +30,6 @@
<!-- Startup (do not modify order of script tags!) -->
<script>
// NOTE: Changes to inline scripts require update of content security policy
self.require = {
baseUrl: `${window.location.origin}/static/out`,
recordStats: true,
@@ -101,7 +100,6 @@
globalThis.MonacoPerformanceMarks.push('willLoadWorkbenchMain', Date.now());
</script>
<script>
// NOTE: Changes to inline scripts require update of content security policy
require(['vs/code/browser/workbench/workbench'], function() {});
</script>
</html>

View File

@@ -31,7 +31,6 @@
<!-- Startup (do not modify order of script tags!) -->
<script>
// NOTE: Changes to inline scripts require update of content security policy
self.require = {
baseUrl: `${window.location.origin}/static/out`,
recordStats: true,

View File

@@ -3,7 +3,10 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { IWorkbenchConstructionOptions, create, URI, Emitter, UriComponents, ICredentialsProvider, IURLCallbackProvider, IWorkspaceProvider, IWorkspace } from 'vs/workbench/workbench.web.api';
import { IWorkbenchConstructionOptions, create, ICredentialsProvider, IURLCallbackProvider, IWorkspaceProvider, IWorkspace, IWindowIndicator, ICommand, IHomeIndicator, IProductQualityChangeHandler } from 'vs/workbench/workbench.web.api';
import product from 'vs/platform/product/common/product';
import { URI, UriComponents } from 'vs/base/common/uri';
import { Event, Emitter } from 'vs/base/common/event';
import { generateUuid } from 'vs/base/common/uuid';
import { CancellationToken } from 'vs/base/common/cancellation';
import { streamToBuffer } from 'vs/base/common/buffer';
@@ -276,6 +279,51 @@ class WorkspaceProvider implements IWorkspaceProvider {
}
}
class WindowIndicator implements IWindowIndicator {
readonly onDidChange = Event.None;
readonly label: string;
readonly tooltip: string;
readonly command: string | undefined;
readonly commandImpl: ICommand | undefined = undefined;
constructor(workspace: IWorkspace) {
let repositoryOwner: string | undefined = undefined;
let repositoryName: string | undefined = undefined;
if (workspace) {
let uri: URI | undefined = undefined;
if (isFolderToOpen(workspace)) {
uri = workspace.folderUri;
} else if (isWorkspaceToOpen(workspace)) {
uri = workspace.workspaceUri;
}
if (uri?.scheme === 'github' || uri?.scheme === 'codespace') {
[repositoryOwner, repositoryName] = uri.authority.split('+');
}
}
if (repositoryName && repositoryOwner) {
this.label = localize('openInDesktopLabel', "$(remote) Open in Desktop");
this.tooltip = localize('openInDesktopTooltip', "Open in Desktop");
this.command = '_web.openInDesktop';
this.commandImpl = {
id: this.command,
handler: () => {
const protocol = product.quality === 'stable' ? 'vscode' : 'vscode-insiders';
window.open(`${protocol}://vscode.git/clone?url=${encodeURIComponent(`https://github.com/${repositoryOwner}/${repositoryName}.git`)}`);
}
};
} else {
this.label = localize('playgroundLabel', "Web Playground");
this.tooltip = this.label;
}
}
}
(function () {
// Find config by checking for DOM
@@ -343,14 +391,44 @@ class WorkspaceProvider implements IWorkspaceProvider {
}
}
// Home Indicator
const homeIndicator: IHomeIndicator = {
href: 'https://github.com/Microsoft/vscode',
icon: 'code',
title: localize('home', "Home")
};
// Commands
const commands: ICommand[] = [];
// Window indicator
const windowIndicator = new WindowIndicator(workspace);
if (windowIndicator.commandImpl) {
commands.push(windowIndicator.commandImpl);
}
// Product Quality Change Handler
const productQualityChangeHandler: IProductQualityChangeHandler = (quality) => {
let queryString = `quality=${quality}`;
// Save all other query params we might have
const query = new URL(document.location.href).searchParams;
query.forEach((value, key) => {
if (key !== 'quality') {
queryString += `&${key}=${value}`;
}
});
window.location.href = `${window.location.origin}?${queryString}`;
};
// Finally create workbench
create(document.body, {
...config,
homeIndicator: {
href: 'https://github.com/Microsoft/vscode',
icon: 'code',
title: localize('home', "Home")
},
homeIndicator,
commands,
windowIndicator,
productQualityChangeHandler,
workspaceProvider: new WorkspaceProvider(workspace, payload),
urlCallbackProvider: new PollingURLCallbackProvider(),
credentialsProvider: new LocalStorageCredentialsProvider()

View File

@@ -82,6 +82,10 @@ import { WebviewMainService } from 'vs/platform/webview/electron-main/webviewMai
import { IWebviewManagerService } from 'vs/platform/webview/common/webviewManagerService';
import { createServer, AddressInfo } from 'net';
import { IOpenExtensionWindowResult } from 'vs/platform/debug/common/extensionHostDebug';
import { IFileService } from 'vs/platform/files/common/files';
import { stripComments } from 'vs/base/common/json';
import { generateUuid } from 'vs/base/common/uuid';
import { VSBuffer } from 'vs/base/common/buffer';
export class CodeApplication extends Disposable {
private windowsMainService: IWindowsMainService | undefined;
@@ -134,11 +138,6 @@ export class CodeApplication extends Disposable {
//
// !!! DO NOT CHANGE without consulting the documentation !!!
//
app.on('remote-get-guest-web-contents', event => {
this.logService.trace('App#on(remote-get-guest-web-contents): prevented');
event.preventDefault();
});
app.on('remote-require', (event, sender, module) => {
this.logService.trace('App#on(remote-require): prevented');
@@ -807,7 +806,7 @@ export class CodeApplication extends Disposable {
return { fileUri: URI.file(path) };
}
private afterWindowOpen(accessor: ServicesAccessor): void {
private async afterWindowOpen(accessor: ServicesAccessor): Promise<void> {
// Signal phase: after window open
this.lifecycleMainService.phase = LifecycleMainPhase.AfterWindowOpen;
@@ -820,6 +819,34 @@ export class CodeApplication extends Disposable {
if (updateService instanceof Win32UpdateService || updateService instanceof LinuxUpdateService || updateService instanceof DarwinUpdateService) {
updateService.initialize();
}
// If enable-crash-reporter argv is undefined then this is a fresh start,
// based on telemetry.enableCrashreporter settings, generate a UUID which
// will be used as crash reporter id and also update the json file.
try {
const fileService = accessor.get(IFileService);
const argvContent = await fileService.readFile(this.environmentService.argvResource);
const argvString = argvContent.value.toString();
const argvJSON = JSON.parse(stripComments(argvString));
if (argvJSON['enable-crash-reporter'] === undefined) {
const enableCrashReporter = this.configurationService.getValue<boolean>('telemetry.enableCrashReporter') ?? true;
const additionalArgvContent = [
'',
' // Allows to disable crash reporting.',
' // Should restart the app if the value is changed.',
` "enable-crash-reporter": ${enableCrashReporter},`,
'',
' // Unique id used for correlating crash reports sent from this instance.',
' // Do not edit this value.',
` "crash-reporter-id": "${generateUuid()}"`,
'}'
];
const newArgvString = argvString.substring(0, argvString.length - 2).concat(',\n', additionalArgvContent.join('\n'));
await fileService.writeFile(this.environmentService.argvResource, VSBuffer.fromString(newArgvString));
}
} catch (error) {
this.logService.error(error);
}
}
private handleRemoteAuthorities(): void {

View File

@@ -289,7 +289,8 @@ class CodeMain {
// Process Info
if (args.status) {
return instantiationService.invokeFunction(async accessor => {
return instantiationService.invokeFunction(async () => {
// Create a diagnostic service connected to the existing shared process
const sharedProcessClient = await connect(environmentService.sharedIPCHandle, 'main');
const diagnosticsChannel = sharedProcessClient.getChannel('diagnostics');
@@ -357,7 +358,10 @@ class CodeMain {
}
private showStartupWarningDialog(message: string, detail: string): void {
dialog.showMessageBox({
// use sync variant here because we likely exit after this method
// due to startup issues and otherwise the dialog seems to disappear
// https://github.com/microsoft/vscode/issues/104493
dialog.showMessageBoxSync({
title: product.nameLong,
type: 'warning',
buttons: [mnemonicButtonLabel(localize({ key: 'close', comment: ['&& denotes a mnemonic'] }, "&&Close"))],

View File

@@ -553,7 +553,7 @@ export class IssueReporter extends Disposable {
private clearSearchResults(): void {
const similarIssues = this.getElementById('similar-issues')!;
similarIssues.innerHTML = '';
similarIssues.innerText = '';
this.numberOfSearchResultsDisplayed = 0;
}
@@ -564,7 +564,7 @@ export class IssueReporter extends Disposable {
window.fetch(`https://api.github.com/search/issues?q=${query}`).then((response) => {
response.json().then(result => {
similarIssues.innerHTML = '';
similarIssues.innerText = '';
if (result && result.items) {
this.displaySearchResults(result.items);
} else {
@@ -713,7 +713,7 @@ export class IssueReporter extends Disposable {
}
}
sourceSelect.innerHTML = '';
sourceSelect.innerText = '';
if (issueType === IssueType.FeatureRequest) {
sourceSelect.append(...[
this.makeOption('', localize('selectSource', "Select source"), true),
@@ -812,11 +812,14 @@ export class IssueReporter extends Disposable {
private validateInput(inputId: string): boolean {
const inputElement = (<HTMLInputElement>this.getElementById(inputId));
const inputValidationMessage = this.getElementById(`${inputId}-empty-error`);
if (!inputElement.value) {
inputElement.classList.add('invalid-input');
inputValidationMessage?.classList.remove('hidden');
return false;
} else {
inputElement.classList.remove('invalid-input');
inputValidationMessage?.classList.add('hidden');
return true;
}
}
@@ -1079,7 +1082,7 @@ export class IssueReporter extends Disposable {
}
private updateExtensionTable(extensions: IssueReporterExtensionData[], numThemeExtensions: number): void {
const target = document.querySelector('.block-extensions .block-info');
const target = document.querySelector<HTMLElement>('.block-extensions .block-info');
if (target) {
if (this.configuration.disableExtensions) {
target.innerHTML = localize('disabledExtensions', "Extensions are disabled");
@@ -1090,7 +1093,7 @@ export class IssueReporter extends Disposable {
extensions = extensions || [];
if (!extensions.length) {
target.innerHTML = 'Extensions: none' + themeExclusionStr;
target.innerText = 'Extensions: none' + themeExclusionStr;
return;
}
@@ -1100,10 +1103,10 @@ export class IssueReporter extends Disposable {
}
private updateSearchedExtensionTable(extensions: IssueReporterExtensionData[]): void {
const target = document.querySelector('.block-searchedExtensions .block-info');
const target = document.querySelector<HTMLElement>('.block-searchedExtensions .block-info');
if (target) {
if (!extensions.length) {
target.innerHTML = 'Extensions: none';
target.innerText = 'Extensions: none';
return;
}

View File

@@ -23,6 +23,7 @@ export default (): string => `
<select id="issue-source" class="inline-form-control" required>
<!-- To be dynamically filled -->
</select>
<div id="issue-source-empty-error" class="validation-error hidden" role="alert">${escape(localize('issueSourceEmptyValidation', "An issue source is required."))}</div>
<div id="problem-source-help-text" class="instructions hidden">${escape(localize('disableExtensionsLabelText', "Try to reproduce the problem after {0}. If the problem only reproduces when extensions are active, it is likely an issue with an extension."))
.replace('{0}', `<span tabIndex=0 role="button" id="disableExtensions" class="workbenchCommand">${escape(localize('disableExtensions', "disabling all extensions and reloading the window"))}</span>`)}
</div>
@@ -43,6 +44,7 @@ export default (): string => `
<div class="input-group">
<label class="inline-label" for="issue-title">${escape(localize('issueTitleLabel', "Title"))} <span class="required-input">*</span></label>
<input id="issue-title" type="text" class="inline-form-control" placeholder="${escape(localize('issueTitleRequired', "Please enter a title."))}" required>
<div id="issue-title-empty-error" class="validation-error hidden" role="alert">${escape(localize('titleEmptyValidation', "A title is required."))}</div>
<div id="issue-title-length-validation-error" class="validation-error hidden" role="alert">${escape(localize('titleLengthValidation', "The title is too long."))}</div>
<small id="similar-issues">
<!-- To be dynamically filled -->
@@ -61,6 +63,7 @@ export default (): string => `
<div class="block-info-text">
<textarea name="description" id="description" placeholder="${escape(localize('details', "Please enter details."))}" required></textarea>
</div>
<div id="description-empty-error" class="validation-error hidden" role="alert">${escape(localize('descriptionEmptyValidation', "A description is required."))}</div>
</div>
<div class="system-info" id="block-container">

View File

@@ -201,9 +201,10 @@ select, input, textarea {
}
.validation-error {
#issue-reporter .validation-error {
font-size: 12px;
margin-top: 1em;
padding: 10px;
border-top: 0px !important;
}
@@ -256,8 +257,7 @@ a {
}
.section .input-group .validation-error {
margin-left: calc(15% + 5px);
padding: 10px;
margin-left: 100px;
}
.section .inline-form-control, .section .inline-label {
@@ -268,7 +268,7 @@ a {
width: 95px;
}
.section .inline-form-control {
.section .inline-form-control, .section .input-group .validation-error {
width: calc(100% - 100px);
}
@@ -294,9 +294,13 @@ a {
margin-left: calc(15% + 1em);
}
.section .inline-form-control {
.section .inline-form-control, .section .input-group .validation-error {
width: calc(85% - 5px);
}
.section .input-group .validation-error {
margin-left: calc(15% + 4px);
}
}
@media (max-width: 620px) {
@@ -308,7 +312,7 @@ a {
margin-left: 1em;
}
.section .inline-form-control {
.section .inline-form-control, .section .input-group .validation-error {
width: 100%;
}

View File

@@ -267,7 +267,7 @@ class ProcessExplorer {
return;
}
container.innerHTML = '';
container.innerText = '';
this.listeners.clear();
const tableHead = document.createElement('thead');