Merge from vscode 2a36b7d0d527bf408bae4f96b8386db9d9455113 (#10237)

This commit is contained in:
Anthony Dresser
2020-04-30 23:41:35 -07:00
committed by GitHub
parent d7a425239b
commit cebbd04d10
60 changed files with 361 additions and 240 deletions

View File

@@ -46,7 +46,7 @@ export class AuthenticationTokenService extends Disposable implements IAuthentic
}
async setToken(token: IUserDataSyncAuthToken | undefined): Promise<void> {
if (token && this._token ? token.token !== this._token.token && token.authenticationProviderId !== this._token.authenticationProviderId : token !== this._token) {
if (token && this._token ? token.token !== this._token.token || token.authenticationProviderId !== this._token.authenticationProviderId : token !== this._token) {
this._token = token;
this._onDidChangeToken.fire(token);
}

View File

@@ -5,6 +5,7 @@
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
import { URI } from 'vs/base/common/uri';
import { $ } from 'vs/base/browser/dom';
export class BrowserClipboardService implements IClipboardService {
@@ -14,39 +15,57 @@ export class BrowserClipboardService implements IClipboardService {
async writeText(text: string, type?: string): Promise<void> {
if (type) {
return; // TODO@sbatten
return; // TODO@sbatten support for writing a specific type into clipboard is unsupported
}
if (navigator.clipboard && navigator.clipboard.writeText) {
return navigator.clipboard.writeText(text);
} else {
const activeElement = <HTMLElement>document.activeElement;
const newTextarea = document.createElement('textarea');
newTextarea.className = 'clipboard-copy';
newTextarea.style.visibility = 'false';
newTextarea.style.height = '1px';
newTextarea.style.width = '1px';
newTextarea.setAttribute('aria-hidden', 'true');
newTextarea.style.position = 'absolute';
newTextarea.style.top = '-1000';
newTextarea.style.left = '-1000';
document.body.appendChild(newTextarea);
newTextarea.value = text;
newTextarea.focus();
newTextarea.select();
document.execCommand('copy');
activeElement.focus();
document.body.removeChild(newTextarea);
// Guard access to navigator.clipboard with try/catch
// as we have seen DOMExceptions in certain browsers
// due to security policies.
try {
return await navigator.clipboard.writeText(text);
} catch (error) {
console.error(error);
}
// Fallback to textarea and execCommand solution
const activeElement = document.activeElement;
const textArea: HTMLTextAreaElement = document.body.appendChild($('textarea', { 'aria-hidden': true }));
textArea.style.height = '1px';
textArea.style.width = '1px';
textArea.style.position = 'absolute';
textArea.value = text;
textArea.focus();
textArea.select();
document.execCommand('copy');
if (activeElement instanceof HTMLElement) {
activeElement.focus();
}
document.body.removeChild(textArea);
return;
}
async readText(type?: string): Promise<string> {
if (type) {
return ''; // TODO@sbatten
return ''; // TODO@sbatten support for reading a specific type from clipboard is unsupported
}
return navigator.clipboard.readText();
// Guard access to navigator.clipboard with try/catch
// as we have seen DOMExceptions in certain browsers
// due to security policies.
try {
return await navigator.clipboard.readText();
} catch (error) {
console.error(error);
return '';
}
}
readTextSync(): string | undefined {

View File

@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import { getErrorMessage, isPromiseCanceledError, canceled } from 'vs/base/common/errors';
import { StatisticType, IGalleryExtension, IExtensionGalleryService, IGalleryExtensionAsset, IQueryOptions, SortBy, SortOrder, IExtensionIdentifier, IReportedExtension, InstallOperation, ITranslation, IGalleryExtensionVersion, IGalleryExtensionAssets, isIExtensionIdentifier } from 'vs/platform/extensionManagement/common/extensionManagement';
import { StatisticType, IGalleryExtension, IExtensionGalleryService, IGalleryExtensionAsset, IQueryOptions, SortBy, SortOrder, IExtensionIdentifier, IReportedExtension, InstallOperation, ITranslation, IGalleryExtensionVersion, IGalleryExtensionAssets, isIExtensionIdentifier, DefaultIconPath } from 'vs/platform/extensionManagement/common/extensionManagement';
import { getGalleryExtensionId, getGalleryExtensionTelemetryData, adoptToGalleryExtensionId } from 'vs/platform/extensionManagement/common/extensionManagementUtil';
import { assign, getOrDefault } from 'vs/base/common/objects';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
@@ -252,7 +252,7 @@ function getIconAsset(version: IRawGalleryExtensionVersion): IGalleryExtensionAs
if (asset) {
return asset;
}
const uri = require.toUrl('./media/defaultIcon.png');
const uri = DefaultIconPath;
return { uri, fallbackUri: uri };
}

View File

@@ -247,7 +247,7 @@ export interface IExtensionTipsService {
}
export const DefaultIconPath = require.toUrl('./media/defaultIcon.png');
export const ExtensionsLabel = localize('extensions', "Extensions");
export const ExtensionsChannelId = 'extensions';
export const PreferencesLabel = localize('preferences', "Preferences");

View File

@@ -141,6 +141,9 @@ export interface IPathData {
// file exists, if false it does not. with
// undefined the state is unknown.
exists?: boolean;
// Specifies if the file should be only be opened if it exists
openOnlyIfExists?: boolean;
}
export interface IOpenFileRequest {