未验证 提交 0c4fa8a7 编写于 作者: B Benjamin Pasero 提交者: GitHub

October changes (#59712)

* fix #59597

* fix #59552

* fix #57997

* Open Workspace button in .code-workspace files (fixes #59305)

* debt - filename => filepath to make method clear
上级 13100f2e
......@@ -71,6 +71,8 @@ export class BaseDropdown extends ActionRunner {
this._register(addDisposableListener(this._label, EventType.KEY_UP, e => {
const event = new StandardKeyboardEvent(e as KeyboardEvent);
if (event.equals(KeyCode.Enter) || event.equals(KeyCode.Space)) {
EventHelper.stop(e, true); // https://github.com/Microsoft/vscode/issues/57997
if (this.visible) {
this.hide();
} else {
......
......@@ -292,7 +292,7 @@ export class LanguagesRegistry {
return [];
}
public getModeIdsFromFilenameOrFirstLine(filepath: string, firstLine?: string): string[] {
public getModeIdsFromFilepathOrFirstLine(filepath: string, firstLine?: string): string[] {
if (!filepath && !firstLine) {
return [];
}
......
......@@ -37,7 +37,7 @@ export interface IModeService {
getMimeForMode(modeId: string): string;
getLanguageName(modeId: string): string;
getModeIdForLanguageName(alias: string): string;
getModeIdByFilenameOrFirstLine(filepath: string, firstLine?: string): string;
getModeIdByFilepathOrFirstLine(filepath: string, firstLine?: string): string;
getModeId(commaSeparatedMimetypesOrCommaSeparatedIds: string): string;
getLanguageIdentifier(modeId: string | LanguageId): LanguageIdentifier;
getConfigurationFiles(modeId: string): URI[];
......@@ -46,5 +46,5 @@ export interface IModeService {
getMode(commaSeparatedMimetypesOrCommaSeparatedIds: string): IMode;
getOrCreateMode(commaSeparatedMimetypesOrCommaSeparatedIds: string): TPromise<IMode>;
getOrCreateModeByLanguageName(languageName: string): TPromise<IMode>;
getOrCreateModeByFilenameOrFirstLine(filepath: string, firstLine?: string): TPromise<IMode>;
getOrCreateModeByFilepathOrFirstLine(filepath: string, firstLine?: string): TPromise<IMode>;
}
......@@ -64,8 +64,8 @@ export class ModeServiceImpl implements IModeService {
return this._registry.getModeIdForLanguageNameLowercase(alias);
}
public getModeIdByFilenameOrFirstLine(filepath: string, firstLine?: string): string {
const modeIds = this._registry.getModeIdsFromFilenameOrFirstLine(filepath, firstLine);
public getModeIdByFilepathOrFirstLine(filepath: string, firstLine?: string): string {
const modeIds = this._registry.getModeIdsFromFilepathOrFirstLine(filepath, firstLine);
if (modeIds.length > 0) {
return modeIds[0];
......@@ -142,9 +142,9 @@ export class ModeServiceImpl implements IModeService {
return null;
}
public getOrCreateModeByFilenameOrFirstLine(filepath: string, firstLine?: string): TPromise<IMode> {
public getOrCreateModeByFilepathOrFirstLine(filepath: string, firstLine?: string): TPromise<IMode> {
return this._onReady().then(() => {
const modeId = this.getModeIdByFilenameOrFirstLine(filepath, firstLine);
const modeId = this.getModeIdByFilepathOrFirstLine(filepath, firstLine);
// Fall back to plain text if no mode was found
return this._getOrCreateMode(modeId || 'plaintext');
});
......
......@@ -42,7 +42,7 @@ export class TextResourceConfigurationService extends Disposable implements ITex
if (model) {
return position ? this.modeService.getLanguageIdentifier(model.getLanguageIdAtPosition(position.lineNumber, position.column)).language : model.getLanguageIdentifier().language;
}
return this.modeService.getModeIdByFilenameOrFirstLine(resource.path);
return this.modeService.getModeIdByFilepathOrFirstLine(resource.path);
}
}
\ No newline at end of file
......@@ -157,7 +157,7 @@ class GotoDefinitionWithMouseEditorContribution implements editorCommon.IEditorC
this.addDecoration(
wordRange,
new MarkdownString().appendCodeblock(this.modeService.getModeIdByFilenameOrFirstLine(textEditorModel.uri.fsPath), previewValue)
new MarkdownString().appendCodeblock(this.modeService.getModeIdByFilepathOrFirstLine(textEditorModel.uri.fsPath), previewValue)
);
ref.dispose();
});
......
......@@ -157,7 +157,7 @@ export function createModel(value: string, language?: string, uri?: URI): ITextM
firstLine = value.substring(0, firstLF);
}
return doCreateModel(value, StaticServices.modeService.get().getOrCreateModeByFilenameOrFirstLine(path, firstLine), uri);
return doCreateModel(value, StaticServices.modeService.get().getOrCreateModeByFilepathOrFirstLine(path, firstLine), uri);
}
return doCreateModel(value, StaticServices.modeService.get().getOrCreateMode(language), uri);
}
......
......@@ -47,7 +47,7 @@ export class MainThreadDocumentContentProviders implements MainThreadDocumentCon
return this._proxy.$provideTextDocumentContent(handle, uri).then(value => {
if (typeof value === 'string') {
const firstLineText = value.substr(0, 1 + value.search(/\r?\n/));
const mode = this._modeService.getOrCreateModeByFilenameOrFirstLine(uri.fsPath, firstLineText);
const mode = this._modeService.getOrCreateModeByFilepathOrFirstLine(uri.fsPath, firstLineText);
return this._modelService.createModel(value, mode, uri);
}
return undefined;
......
......@@ -350,7 +350,7 @@ export function getIconClasses(modelService: IModelService, modeService: IModeSe
// Configured Language
let configuredLangId = getConfiguredLangId(modelService, resource);
configuredLangId = configuredLangId || modeService.getModeIdByFilenameOrFirstLine(path);
configuredLangId = configuredLangId || modeService.getModeIdByFilepathOrFirstLine(path);
if (configuredLangId) {
classes.push(`${cssEscape(configuredLangId)}-lang-file-icon`);
}
......
......@@ -49,6 +49,8 @@ import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
import { isMacintosh } from 'vs/base/common/platform';
import { AllEditorsPicker, ActiveEditorGroupPicker } from 'vs/workbench/browser/parts/editor/editorPicker';
import { Schemas } from 'vs/base/common/network';
import { registerEditorContribution } from 'vs/editor/browser/editorExtensions';
import { OpenWorkspaceButtonContribution } from 'vs/workbench/browser/parts/editor/editorWidgets';
// Register String Editor
Registry.as<IEditorRegistry>(EditorExtensions.Editors).registerEditor(
......@@ -213,6 +215,9 @@ class SideBySideEditorInputFactory implements IEditorInputFactory {
Registry.as<IEditorInputFactoryRegistry>(EditorInputExtensions.EditorInputFactories).registerEditorInputFactory(SideBySideEditorInput.ID, SideBySideEditorInputFactory);
// Register Editor Contributions
registerEditorContribution(OpenWorkspaceButtonContribution);
// Register Editor Status
const statusBar = Registry.as<IStatusbarRegistry>(StatusExtensions.Statusbar);
statusBar.registerStatusbarItem(new StatusbarItemDescriptor(EditorStatus, StatusbarAlignment.RIGHT, 100 /* towards the left of the right hand side */));
......
......@@ -54,6 +54,7 @@ import { IQuickInputService, IQuickPickItem, QuickPickInput } from 'vs/platform/
import { getIconClasses } from 'vs/workbench/browser/labels';
import { timeout } from 'vs/base/common/async';
import { INotificationHandle, INotificationService, Severity } from 'vs/platform/notification/common/notification';
import { once } from 'vs/base/common/event';
class SideBySideEditorEncodingSupport implements IEncodingSupport {
constructor(private master: IEncodingSupport, private details: IEncodingSupport) { }
......@@ -515,6 +516,10 @@ export class EditorStatus implements IStatusbarItem {
}
}]
);
once(this.screenReaderNotification.onDidClose)(() => {
this.screenReaderNotification = null;
});
}
}
......@@ -690,7 +695,6 @@ export class EditorStatus implements IStatusbarItem {
if (screenReaderMode === false && this.screenReaderNotification) {
this.screenReaderNotification.close();
this.screenReaderNotification = null;
}
this.updateState({ screenReaderMode: screenReaderMode });
......@@ -972,7 +976,7 @@ export class ChangeModeAction extends Action {
// Find mode
let mode: TPromise<IMode>;
if (pick === autoDetectMode) {
mode = this.modeService.getOrCreateModeByFilenameOrFirstLine(toResource(activeEditor, { supportSideBySide: true }).fsPath, textModel.getLineContent(1));
mode = this.modeService.getOrCreateModeByFilepathOrFirstLine(toResource(activeEditor, { supportSideBySide: true }).fsPath, textModel.getLineContent(1));
} else {
mode = this.modeService.getOrCreateModeByLanguageName(pick.label);
}
......@@ -987,7 +991,7 @@ export class ChangeModeAction extends Action {
private configureFileAssociation(resource: uri): void {
const extension = paths.extname(resource.fsPath);
const basename = paths.basename(resource.fsPath);
const currentAssociation = this.modeService.getModeIdByFilenameOrFirstLine(basename);
const currentAssociation = this.modeService.getModeIdByFilepathOrFirstLine(basename);
const languages = this.modeService.getRegisteredLanguageNames();
const picks: IQuickPickItem[] = languages.sort().map((lang, index) => {
......
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import { Widget } from 'vs/base/browser/ui/widget';
import { IOverlayWidget, ICodeEditor, IOverlayWidgetPosition, OverlayWidgetPositionPreference } from 'vs/editor/browser/editorBrowser';
import { Event, Emitter } from 'vs/base/common/event';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { $, append } from 'vs/base/browser/dom';
import { attachStylerCallback } from 'vs/platform/theme/common/styler';
import { buttonBackground, buttonForeground, editorBackground, editorForeground, contrastBorder } from 'vs/platform/theme/common/colorRegistry';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IWindowService } from 'vs/platform/windows/common/windows';
import { IWorkspaceContextService, WorkbenchState } from 'vs/platform/workspace/common/workspace';
import { Schemas } from 'vs/base/common/network';
import { WORKSPACE_EXTENSION } from 'vs/platform/workspaces/common/workspaces';
import { extname } from 'vs/base/common/paths';
import { Disposable, dispose } from 'vs/base/common/lifecycle';
import { localize } from 'vs/nls';
import { IEditorContribution } from 'vs/editor/common/editorCommon';
import { isEqual } from 'vs/base/common/resources';
export class FloatingClickWidget extends Widget implements IOverlayWidget {
private _onClick: Emitter<void> = this._register(new Emitter<void>());
get onClick(): Event<void> { return this._onClick.event; }
private _domNode: HTMLElement;
constructor(
private editor: ICodeEditor,
private label: string,
keyBindingAction: string,
@IKeybindingService keybindingService: IKeybindingService,
@IThemeService private themeService: IThemeService
) {
super();
if (keyBindingAction) {
const keybinding = keybindingService.lookupKeybinding(keyBindingAction);
if (keybinding) {
this.label += ` (${keybinding.getLabel()})`;
}
}
}
getId(): string {
return 'editor.overlayWidget.floatingClickWidget';
}
getDomNode(): HTMLElement {
return this._domNode;
}
getPosition(): IOverlayWidgetPosition {
return {
preference: OverlayWidgetPositionPreference.BOTTOM_RIGHT_CORNER
};
}
render() {
this._domNode = $('.floating-click-widget');
this._register(attachStylerCallback(this.themeService, { buttonBackground, buttonForeground, editorBackground, editorForeground, contrastBorder }, colors => {
this._domNode.style.backgroundColor = colors.buttonBackground ? colors.buttonBackground.toString() : colors.editorBackground.toString();
this._domNode.style.color = colors.buttonForeground ? colors.buttonForeground.toString() : colors.editorForeground.toString();
const borderColor = colors.contrastBorder ? colors.contrastBorder.toString() : null;
this._domNode.style.borderWidth = borderColor ? '1px' : null;
this._domNode.style.borderStyle = borderColor ? 'solid' : null;
this._domNode.style.borderColor = borderColor;
}));
append(this._domNode, $('')).textContent = this.label;
this.onclick(this._domNode, e => this._onClick.fire());
this.editor.addOverlayWidget(this);
}
dispose(): void {
this.editor.removeOverlayWidget(this);
super.dispose();
}
}
export class OpenWorkspaceButtonContribution extends Disposable implements IEditorContribution {
static get(editor: ICodeEditor): OpenWorkspaceButtonContribution {
return editor.getContribution<OpenWorkspaceButtonContribution>(OpenWorkspaceButtonContribution.ID);
}
private static readonly ID = 'editor.contrib.openWorkspaceButton';
private openWorkspaceButton: FloatingClickWidget;
constructor(
private editor: ICodeEditor,
@IInstantiationService private instantiationService: IInstantiationService,
@IWindowService private windowService: IWindowService,
@IWorkspaceContextService private contextService: IWorkspaceContextService
) {
super();
this.update();
this.registerListeners();
}
private registerListeners(): void {
this._register(this.editor.onDidChangeModel(e => this.update()));
}
getId(): string {
return OpenWorkspaceButtonContribution.ID;
}
private update(): void {
if (!this.shouldShowButton(this.editor)) {
this.disposeOpenWorkspaceWidgetRenderer();
return;
}
this.createOpenWorkspaceWidgetRenderer();
}
private shouldShowButton(editor: ICodeEditor): boolean {
const model = editor.getModel();
if (!model) {
return false; // we need a model
}
if (model.uri.scheme !== Schemas.file || extname(model.uri.fsPath) !== `.${WORKSPACE_EXTENSION}`) {
return false; // we need a local workspace file
}
if (this.contextService.getWorkbenchState() === WorkbenchState.WORKSPACE) {
const workspaceConfiguration = this.contextService.getWorkspace().configuration;
if (workspaceConfiguration && isEqual(workspaceConfiguration, model.uri)) {
return false; // already inside workspace
}
}
return true;
}
private createOpenWorkspaceWidgetRenderer(): void {
if (!this.openWorkspaceButton) {
this.openWorkspaceButton = this.instantiationService.createInstance(FloatingClickWidget, this.editor, localize('openWorkspace', "Open Workspace"), null);
this._register(this.openWorkspaceButton.onClick(() => this.windowService.openWindow([this.editor.getModel().uri])));
this.openWorkspaceButton.render();
}
}
private disposeOpenWorkspaceWidgetRenderer(): void {
this.openWorkspaceButton = dispose(this.openWorkspaceButton);
}
dispose(): void {
this.disposeOpenWorkspaceWidgetRenderer();
super.dispose();
}
}
\ No newline at end of file
......@@ -73,14 +73,20 @@ export class NotificationsToasts extends Themable {
this.mapNotificationToToast = new Map<INotificationViewItem, INotificationToast>();
this.notificationsToastsVisibleContextKey = NotificationsToastsVisibleContext.bindTo(contextKeyService);
// Show toast for initial notifications if any
model.notifications.forEach(notification => this.addToast(notification));
this.registerListeners();
}
private registerListeners(): void {
this._register(this.model.onDidNotificationChange(e => this.onDidNotificationChange(e)));
// Wait for the running phase to ensure we can draw notifications properly
this.lifecycleService.when(LifecyclePhase.Running).then(() => {
// Show toast for initial notifications if any
this.model.notifications.forEach(notification => this.addToast(notification));
// Update toasts on notification changes
this._register(this.model.onDidNotificationChange(e => this.onDidNotificationChange(e)));
});
}
private onDidNotificationChange(e: INotificationChangeEvent): void {
......@@ -205,16 +211,12 @@ export class NotificationsToasts extends Themable {
// Context Key
this.notificationsToastsVisibleContextKey.set(true);
// Animate In if we are in a running session (otherwise just show directly)
if (this.lifecycleService.phase >= LifecyclePhase.Running) {
addClass(notificationToast, 'notification-fade-in');
itemDisposeables.push(addDisposableListener(notificationToast, 'transitionend', () => {
removeClass(notificationToast, 'notification-fade-in');
addClass(notificationToast, 'notification-fade-in-done');
}));
} else {
// Animate in
addClass(notificationToast, 'notification-fade-in');
itemDisposeables.push(addDisposableListener(notificationToast, 'transitionend', () => {
removeClass(notificationToast, 'notification-fade-in');
addClass(notificationToast, 'notification-fade-in-done');
}
}));
}
private removeToast(item: INotificationViewItem): void {
......
......@@ -61,7 +61,7 @@ export class UntitledEditorModel extends BaseTextEditorModel implements IEncodin
protected getOrCreateMode(modeService: IModeService, modeId: string, firstLineText?: string): TPromise<IMode> {
if (!modeId || modeId === PLAINTEXT_MODE_ID) {
return modeService.getOrCreateModeByFilenameOrFirstLine(this.resource.fsPath, firstLineText); // lookup mode via resource path if the provided modeId is unspecific
return modeService.getOrCreateModeByFilepathOrFirstLine(this.resource.fsPath, firstLineText); // lookup mode via resource path if the provided modeId is unspecific
}
return super.getOrCreateMode(modeService, modeId, firstLineText);
......
......@@ -60,7 +60,7 @@ export class ResourceContextKey extends Disposable implements IContextKey<URI> {
this._resourceKey.set(value);
this._schemeKey.set(value && value.scheme);
this._filenameKey.set(value && paths.basename(value.fsPath));
this._langIdKey.set(value && this._modeService.getModeIdByFilenameOrFirstLine(value.fsPath));
this._langIdKey.set(value && this._modeService.getModeIdByFilepathOrFirstLine(value.fsPath));
this._extensionKey.set(value && paths.extname(value.fsPath));
this._hasResource.set(!!value);
this._isfileSystemResource.set(value && this._fileService.canHandleResource(value));
......
......@@ -124,7 +124,7 @@ export class CommentNode extends Disposable {
const container = dom.append(this._commentEditContainer, dom.$('.edit-textarea'));
this._commentEditor = this.instantiationService.createInstance(SimpleCommentEditor, container, SimpleCommentEditor.getEditorOptions());
const resource = URI.parse(`comment:commentinput-${this.comment.commentId}-${Date.now()}.md`);
this._commentEditorModel = this.modelService.createModel('', this.modeService.getOrCreateModeByFilenameOrFirstLine(resource.path), resource, true);
this._commentEditorModel = this.modelService.createModel('', this.modeService.getOrCreateModeByFilepathOrFirstLine(resource.path), resource, true);
this._commentEditor.setModel(this._commentEditorModel);
this._commentEditor.setValue(this.comment.body.value);
......
......@@ -265,7 +265,7 @@ export class ReviewZoneWidget extends ZoneWidget {
this._commentEditor = this.instantiationService.createInstance(SimpleCommentEditor, this._commentForm, SimpleCommentEditor.getEditorOptions());
const modeId = hasExistingComments ? this._commentThread.threadId : ++INMEM_MODEL_ID;
const resource = URI.parse(`${COMMENT_SCHEME}:commentinput-${modeId}.md`);
const model = this.modelService.createModel('', this.modeService.getOrCreateModeByFilenameOrFirstLine(resource.path), resource, true);
const model = this.modelService.createModel('', this.modeService.getOrCreateModeByFilepathOrFirstLine(resource.path), resource, true);
this._localToDispose.push(model);
this._commentEditor.setModel(model);
this._localToDispose.push(this._commentEditor);
......
......@@ -34,7 +34,7 @@ import { RemoveBreakpointAction } from 'vs/workbench/parts/debug/browser/debugAc
import { IDebugEditorContribution, IDebugService, State, IBreakpoint, EDITOR_CONTRIBUTION_ID, CONTEXT_BREAKPOINT_WIDGET_VISIBLE, IStackFrame, IDebugConfiguration, IExpression, IExceptionInfo, BreakpointWidgetContext } from 'vs/workbench/parts/debug/common/debug';
import { BreakpointWidget } from 'vs/workbench/parts/debug/electron-browser/breakpointWidget';
import { ExceptionWidget } from 'vs/workbench/parts/debug/browser/exceptionWidget';
import { FloatingClickWidget } from 'vs/workbench/parts/preferences/browser/preferencesWidgets';
import { FloatingClickWidget } from 'vs/workbench/browser/parts/editor/editorWidgets';
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { Position } from 'vs/editor/common/core/position';
import { CoreEditingCommands } from 'vs/editor/browser/controller/coreCommands';
......
......@@ -359,7 +359,7 @@ export class ExtensionsListView extends ViewletPanel {
const keywords = this.tipsService.getKeywordsForExtension(ext);
// Get mode name
const modeId = this.modeService.getModeIdByFilenameOrFirstLine(`.${ext}`);
const modeId = this.modeService.getModeIdByFilepathOrFirstLine(`.${ext}`);
const languageName = modeId && this.modeService.getLanguageName(modeId);
const languageTag = languageName ? ` tag:"${languageName}"` : '';
......
......@@ -194,7 +194,7 @@ export class FileOnDiskContentProvider implements ITextModelContentProvider {
if (fileOnDiskModel) {
mode = this.modeService.getOrCreateMode(fileOnDiskModel.getModeId());
} else {
mode = this.modeService.getOrCreateModeByFilenameOrFirstLine(fileOnDiskResource.fsPath);
mode = this.modeService.getOrCreateModeByFilepathOrFirstLine(fileOnDiskResource.fsPath);
}
codeEditorModel = this.modelService.createModel(content.value, mode, resource);
......
......@@ -20,7 +20,7 @@ import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
import { SnippetController2 } from 'vs/editor/contrib/snippet/snippetController2';
import { SmartSnippetInserter } from 'vs/workbench/parts/preferences/common/smartSnippetInserter';
import { DefineKeybindingOverlayWidget } from 'vs/workbench/parts/preferences/browser/keybindingWidgets';
import { FloatingClickWidget } from 'vs/workbench/parts/preferences/browser/preferencesWidgets';
import { FloatingClickWidget } from 'vs/workbench/browser/parts/editor/editorWidgets';
import { parseTree, Node } from 'vs/base/common/json';
import { ScanCodeBinding } from 'vs/base/common/scanCode';
import { EditorContextKeys } from 'vs/editor/common/editorContextKeys';
......
......@@ -12,19 +12,18 @@ import { Widget } from 'vs/base/browser/ui/widget';
import { Event, Emitter } from 'vs/base/common/event';
import { IKeyboardEvent, StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
import { KeyCode } from 'vs/base/common/keyCodes';
import { ICodeEditor, IOverlayWidget, IOverlayWidgetPosition, OverlayWidgetPositionPreference, IViewZone, IEditorMouseEvent, MouseTargetType } from 'vs/editor/browser/editorBrowser';
import { ICodeEditor, IViewZone, IEditorMouseEvent, MouseTargetType } from 'vs/editor/browser/editorBrowser';
import { InputBox, IInputOptions } from 'vs/base/browser/ui/inputbox/inputBox';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IContextViewService, IContextMenuService } from 'vs/platform/contextview/browser/contextView';
import { ISettingsGroup } from 'vs/workbench/services/preferences/common/preferences';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { IWorkspaceContextService, WorkbenchState, IWorkspaceFolder } from 'vs/platform/workspace/common/workspace';
import { IAction, Action } from 'vs/base/common/actions';
import { attachInputBoxStyler, attachStylerCallback } from 'vs/platform/theme/common/styler';
import { IThemeService, registerThemingParticipant, ITheme, ICssStyleCollector } from 'vs/platform/theme/common/themeService';
import { Position } from 'vs/editor/common/core/position';
import { ICursorPositionChangedEvent } from 'vs/editor/common/controller/cursorEvents';
import { buttonBackground, buttonForeground, badgeForeground, badgeBackground, contrastBorder, errorForeground, focusBorder, activeContrastBorder, editorBackground, editorForeground } from 'vs/platform/theme/common/colorRegistry';
import { badgeForeground, badgeBackground, contrastBorder, errorForeground, focusBorder, activeContrastBorder } from 'vs/platform/theme/common/colorRegistry';
import { IContextKey } from 'vs/platform/contextkey/common/contextkey';
import { ActionBar, ActionsOrientation, BaseActionItem } from 'vs/base/browser/ui/actionbar/actionbar';
import { MarkdownString } from 'vs/base/common/htmlContent';
......@@ -408,7 +407,7 @@ export class FolderSettingsActionItem extends BaseActionItem {
this.contextMenuService.showContextMenu({
getAnchor: () => this.container,
getActions: () => TPromise.as(this.getDropdownMenuActions()),
getActionItem: (action) => null,
getActionItem: () => null,
onHide: () => {
this.anchorElement.blur();
}
......@@ -705,67 +704,6 @@ export class SearchWidget extends Widget {
}
}
export class FloatingClickWidget extends Widget implements IOverlayWidget {
private _domNode: HTMLElement;
private readonly _onClick: Emitter<void> = this._register(new Emitter<void>());
public readonly onClick: Event<void> = this._onClick.event;
constructor(
private editor: ICodeEditor,
private label: string,
keyBindingAction: string,
@IKeybindingService keybindingService: IKeybindingService,
@IThemeService private themeService: IThemeService
) {
super();
if (keyBindingAction) {
let keybinding = keybindingService.lookupKeybinding(keyBindingAction);
if (keybinding) {
this.label += ' (' + keybinding.getLabel() + ')';
}
}
}
public render() {
this._domNode = DOM.$('.floating-click-widget');
this._register(attachStylerCallback(this.themeService, { buttonBackground, buttonForeground, editorBackground, editorForeground, contrastBorder }, colors => {
this._domNode.style.backgroundColor = colors.buttonBackground ? colors.buttonBackground.toString() : colors.editorBackground.toString();
this._domNode.style.color = colors.buttonForeground ? colors.buttonForeground.toString() : colors.editorForeground.toString();
const borderColor = colors.contrastBorder ? colors.contrastBorder.toString() : null;
this._domNode.style.borderWidth = borderColor ? '1px' : null;
this._domNode.style.borderStyle = borderColor ? 'solid' : null;
this._domNode.style.borderColor = borderColor;
}));
DOM.append(this._domNode, DOM.$('')).textContent = this.label;
this.onclick(this._domNode, e => this._onClick.fire());
this.editor.addOverlayWidget(this);
}
public dispose(): void {
this.editor.removeOverlayWidget(this);
super.dispose();
}
public getId(): string {
return 'editor.overlayWidget.floatingClickWidget';
}
public getDomNode(): HTMLElement {
return this._domNode;
}
public getPosition(): IOverlayWidgetPosition {
return {
preference: OverlayWidgetPositionPreference.BOTTOM_RIGHT_CORNER
};
}
}
export class EditPreferenceWidget<T> extends Disposable {
public static readonly GLYPH_MARGIN_CLASS_NAME = 'edit-preferences-widget';
......
......@@ -222,7 +222,7 @@ class Snapper {
}
public captureSyntaxTokens(fileName: string, content: string): TPromise<IToken[]> {
return this.modeService.getOrCreateModeByFilenameOrFirstLine(fileName).then(mode => {
return this.modeService.getOrCreateModeByFilepathOrFirstLine(fileName).then(mode => {
return this.textMateService.createGrammar(mode.getId()).then((grammar) => {
let lines = content.split(/\r\n|\r|\n/);
......
......@@ -42,7 +42,7 @@ export class WalkThroughContentProvider implements ITextModelContentProvider, IW
return content.then(content => {
let codeEditorModel = this.modelService.getModel(resource);
if (!codeEditorModel) {
codeEditorModel = this.modelService.createModel(content, this.modeService.getOrCreateModeByFilenameOrFirstLine(resource.fsPath), resource);
codeEditorModel = this.modelService.createModel(content, this.modeService.getOrCreateModeByFilepathOrFirstLine(resource.fsPath), resource);
} else {
this.modelService.updateModel(codeEditorModel, content);
}
......
......@@ -494,7 +494,7 @@ export class TextFileEditorModel extends BaseTextEditorModel implements ITextFil
}
protected getOrCreateMode(modeService: IModeService, preferredModeIds: string, firstLineText?: string): TPromise<IMode> {
return modeService.getOrCreateModeByFilenameOrFirstLine(this.resource.fsPath, firstLineText);
return modeService.getOrCreateModeByFilepathOrFirstLine(this.resource.fsPath, firstLineText);
}
private onModelContentChanged(): void {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册