Merge from vscode 4c9161a3f125f5a788aafa73a4ecfcb27dcfc319 (#9143)

* Merge from vscode 4c9161a3f125f5a788aafa73a4ecfcb27dcfc319

* minor spacing fix
This commit is contained in:
Anthony Dresser
2020-02-13 21:20:36 -06:00
committed by GitHub
parent 0c56d44e4f
commit 71375808b9
57 changed files with 706 additions and 510 deletions

View File

@@ -55,6 +55,7 @@ import { withNullAsUndefined } from 'vs/base/common/types';
import { IFilesConfigurationService } from 'vs/workbench/services/filesConfiguration/common/filesConfigurationService';
import { EditorAutoSave } from 'vs/workbench/browser/parts/editor/editorAutoSave';
import { ThemeIcon } from 'vs/platform/theme/common/themeService';
import { PLAINTEXT_MODE_ID } from 'vs/editor/common/modes/modesRegistry';
// Register String Editor
Registry.as<IEditorRegistry>(EditorExtensions.Editors).registerEditor(
@@ -134,9 +135,21 @@ class UntitledTextEditorInputFactory implements IEditorInputFactory {
resource = toLocalResource(resource, this.environmentService.configuration.remoteAuthority); // untitled with associated file path use the local schema
}
// Mode: only remember mode if it is either specific (not text)
// or if the mode was explicitly set by the user. We want to preserve
// this information across restarts and not set the mode unless
// this is the case.
let modeId: string | undefined;
const modeIdCandidate = untitledTextEditorInput.getMode();
if (modeIdCandidate !== PLAINTEXT_MODE_ID) {
modeId = modeIdCandidate;
} else if (untitledTextEditorInput.model.hasModeSetExplicitly) {
modeId = modeIdCandidate;
}
const serialized: ISerializedUntitledTextEditorInput = {
resourceJSON: resource.toJSON(),
modeId: untitledTextEditorInput.getMode(),
modeId,
encoding: untitledTextEditorInput.getEncoding()
};

View File

@@ -214,6 +214,10 @@ export class TextResourceEditor extends AbstractTextResourceEditor {
}
private onDidEditorPaste(e: IPasteEvent, codeEditor: ICodeEditor): void {
if (this.input instanceof UntitledTextEditorInput && this.input.model.hasModeSetExplicitly) {
return; // do not override mode if it was set explicitly
}
if (e.range.startLineNumber !== 1 || e.range.startColumn !== 1) {
return; // only when pasting into first line, first column (= empty document)
}

View File

@@ -222,4 +222,5 @@ export function registerNotificationCommands(center: INotificationsCenterControl
MenuRegistry.appendMenuItem(MenuId.CommandPalette, { command: { id: SHOW_NOTIFICATIONS_CENTER, title: { value: localize('showNotifications', "Show Notifications"), original: 'Show Notifications' }, category }, when: NotificationsCenterVisibleContext.toNegated() });
MenuRegistry.appendMenuItem(MenuId.CommandPalette, { command: { id: HIDE_NOTIFICATIONS_CENTER, title: { value: localize('hideNotifications', "Hide Notifications"), original: 'Hide Notifications' }, category }, when: NotificationsCenterVisibleContext });
MenuRegistry.appendMenuItem(MenuId.CommandPalette, { command: { id: CLEAR_ALL_NOTIFICATIONS, title: { value: localize('clearAllNotifications', "Clear All Notifications"), original: 'Clear All Notifications' }, category } });
}
MenuRegistry.appendMenuItem(MenuId.CommandPalette, { command: { id: FOCUS_NOTIFICATION_TOAST, title: { value: localize('focusNotificationToasts', "Focus Notification Toast"), original: 'Focus Notification Toast' }, category }, when: NotificationsToastsVisibleContext });
}

View File

@@ -93,20 +93,16 @@ class BrowserMain extends Disposable {
// Layout
const viewport = platform.isIOS && (<any>window).visualViewport ? (<any>window).visualViewport /** Visual viewport */ : window /** Layout viewport */;
this._register(addDisposableListener(viewport, EventType.RESIZE, () => {
workbench.layout();
}));
this._register(addDisposableListener(viewport, EventType.RESIZE, () => workbench.layout()));
// Prevent the back/forward gestures in macOS
this._register(addDisposableListener(this.domElement, EventType.WHEEL, (e) => {
e.preventDefault();
}, { passive: false }));
this._register(addDisposableListener(this.domElement, EventType.WHEEL, e => e.preventDefault(), { passive: false }));
// Prevent native context menus in web
this._register(addDisposableListener(this.domElement, EventType.CONTEXT_MENU, (e) => EventHelper.stop(e, true)));
this._register(addDisposableListener(this.domElement, EventType.CONTEXT_MENU, e => EventHelper.stop(e, true)));
// Prevent default navigation on drop
this._register(addDisposableListener(this.domElement, EventType.DROP, (e) => EventHelper.stop(e, true)));
this._register(addDisposableListener(this.domElement, EventType.DROP, e => EventHelper.stop(e, true)));
// Workbench Lifecycle
this._register(workbench.onBeforeShutdown(event => {