提交 788caba5 编写于 作者: D Daniel Imms

Revert "search gallery for specific language extensions"

This reverts commit 9b01ce13.

This commit broken the build, fix wasn't immediately clear.
上级 513c8e2e
......@@ -45,7 +45,6 @@ import { Selection } from 'vs/editor/common/core/selection';
import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService';
import { TabFocus } from 'vs/editor/common/config/commonEditorConfig';
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
import { ShowLanguageExtensionsAction } from 'vs/workbench/parts/extensions/electron-browser/extensionsActions';
function getCodeEditor(editorWidget: IEditor): ICommonCodeEditor {
if (editorWidget) {
......@@ -682,8 +681,7 @@ export class ChangeModeAction extends Action {
@IConfigurationEditingService private configurationEditingService: IConfigurationEditingService,
@IMessageService private messageService: IMessageService,
@IWorkspaceConfigurationService private configurationService: IWorkspaceConfigurationService,
@IQuickOpenService private quickOpenService: IQuickOpenService,
@IInstantiationService private instantiationService: IInstantiationService
@IQuickOpenService private quickOpenService: IQuickOpenService
) {
super(actionId, actionLabel);
}
......@@ -742,17 +740,12 @@ export class ChangeModeAction extends Action {
// Offer action to configure via settings
let configureModeAssociations: IPickOpenEntry;
let galleryAction: Action;
if (fileinput) {
const resource = fileinput.getResource();
const ext = paths.extname(resource.fsPath) || paths.basename(resource.fsPath);
galleryAction = this.instantiationService.createInstance(ShowLanguageExtensionsAction, ext);
if (galleryAction.enabled) {
picks.unshift(galleryAction);
}
configureModeAssociations = {
label: nls.localize('configureAssociationsExt', "Configure File Association for '{0}'...", paths.extname(resource.fsPath) || paths.basename(resource.fsPath))
};
configureModeAssociations = { label: nls.localize('configureAssociationsExt', "Configure File Association for '{0}'...", ext) };
picks.unshift(configureModeAssociations);
}
......@@ -764,51 +757,45 @@ export class ChangeModeAction extends Action {
picks.unshift(autoDetectMode);
}
return this.quickOpenService.pick(picks, { placeHolder: nls.localize('pickLanguage', "Select Language Mode") }).then(pick => {
if (!pick) {
return;
}
return this.quickOpenService.pick(picks, { placeHolder: nls.localize('pickLanguage', "Select Language Mode") }).then(language => {
if (language) {
if (pick === galleryAction) {
galleryAction.run();
return;
}
// User decided to permanently configure associations, return right after
if (language === configureModeAssociations) {
this.configureFileAssociation(fileinput.getResource());
return;
}
// User decided to permanently configure associations, return right after
if (pick === configureModeAssociations) {
this.configureFileAssociation(fileinput.getResource());
return;
}
// Change mode for active editor
activeEditor = this.editorService.getActiveEditor();
if (activeEditor instanceof BaseTextEditor) {
const editorWidget = activeEditor.getControl();
const models: IModel[] = [];
// Change mode for active editor
activeEditor = this.editorService.getActiveEditor();
if (activeEditor instanceof BaseTextEditor) {
const editorWidget = activeEditor.getControl();
const models: IModel[] = [];
const textModel = getTextModel(editorWidget);
if (textModel) {
models.push(textModel);
}
const textModel = getTextModel(editorWidget);
if (textModel) {
models.push(textModel);
}
// Support for original side of diff
const model = editorWidget.getModel();
if (model && !!(<IDiffEditorModel>model).original) {
models.push((<IDiffEditorModel>model).original);
}
// Support for original side of diff
const model = editorWidget.getModel();
if (model && !!(<IDiffEditorModel>model).original) {
models.push((<IDiffEditorModel>model).original);
}
// Find mode
let mode: TPromise<IMode>;
if (language === autoDetectMode) {
mode = this.modeService.getOrCreateModeByFilenameOrFirstLine(getUntitledOrFileResource(activeEditor.input, true).fsPath, textModel.getLineContent(1));
} else {
mode = this.modeService.getOrCreateModeByLanguageName(language.label);
}
// Find mode
let mode: TPromise<IMode>;
if (pick === autoDetectMode) {
mode = this.modeService.getOrCreateModeByFilenameOrFirstLine(getUntitledOrFileResource(activeEditor.input, true).fsPath, textModel.getLineContent(1));
} else {
mode = this.modeService.getOrCreateModeByLanguageName(pick.label);
// Change mode
models.forEach(textModel => {
this.modelService.setMode(textModel, mode);
});
}
// Change mode
models.forEach(textModel => {
this.modelService.setMode(textModel, mode);
});
}
});
}
......
......@@ -16,7 +16,7 @@ import { IContextMenuService } from 'vs/platform/contextview/browser/contextView
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import { ReloadWindowAction } from 'vs/workbench/electron-browser/actions';
import { IExtension, ExtensionState, IExtensionsWorkbenchService, VIEWLET_ID, IExtensionsViewlet, ConfigurationKey } from './extensions';
import { LocalExtensionType, IExtensionGalleryService } from 'vs/platform/extensionManagement/common/extensionManagement';
import { LocalExtensionType } from 'vs/platform/extensionManagement/common/extensionManagement';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IMessageService } from 'vs/platform/message/common/message';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
......@@ -677,29 +677,6 @@ export class ShowDisabledExtensionsAction extends Action {
}
}
export class ShowLanguageExtensionsAction extends Action {
static ID = 'workbench.extensions.action.showLanguageExtensions';
constructor(
private extension: string,
@IViewletService private viewletService: IViewletService,
@IExtensionGalleryService galleryService: IExtensionGalleryService
) {
super(ShowLanguageExtensionsAction.ID, localize('showLanguageExtensions', "Search Gallery Extensions for '{0}'...", extension), null, true);
this.enabled = galleryService.isEnabled();
}
run(): TPromise<void> {
return this.viewletService.openViewlet(VIEWLET_ID, true)
.then(viewlet => viewlet as IExtensionsViewlet)
.then(viewlet => {
viewlet.search(`tag:__ext_${this.extension.replace(/^\./, '')}`);
viewlet.focus();
});
}
}
export class ClearExtensionsInputAction extends ShowInstalledExtensionsAction {
static ID = 'workbench.extensions.action.clearExtensionsInput';
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册