Skip to content

Commit 0c4fa8a

Browse files
authored
October changes (microsoft#59712)
* fix microsoft#59597 * fix microsoft#59552 * fix microsoft#57997 * Open Workspace button in .code-workspace files (fixes microsoft#59305) * debt - filename => filepath to make method clear
1 parent 13100f2 commit 0c4fa8a

25 files changed

Lines changed: 224 additions & 104 deletions

File tree

src/vs/base/browser/ui/dropdown/dropdown.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ export class BaseDropdown extends ActionRunner {
7171
this._register(addDisposableListener(this._label, EventType.KEY_UP, e => {
7272
const event = new StandardKeyboardEvent(e as KeyboardEvent);
7373
if (event.equals(KeyCode.Enter) || event.equals(KeyCode.Space)) {
74+
EventHelper.stop(e, true); // https://github.com/Microsoft/vscode/issues/57997
75+
7476
if (this.visible) {
7577
this.hide();
7678
} else {

src/vs/editor/common/services/languagesRegistry.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ export class LanguagesRegistry {
292292
return [];
293293
}
294294

295-
public getModeIdsFromFilenameOrFirstLine(filepath: string, firstLine?: string): string[] {
295+
public getModeIdsFromFilepathOrFirstLine(filepath: string, firstLine?: string): string[] {
296296
if (!filepath && !firstLine) {
297297
return [];
298298
}

src/vs/editor/common/services/modeService.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export interface IModeService {
3737
getMimeForMode(modeId: string): string;
3838
getLanguageName(modeId: string): string;
3939
getModeIdForLanguageName(alias: string): string;
40-
getModeIdByFilenameOrFirstLine(filepath: string, firstLine?: string): string;
40+
getModeIdByFilepathOrFirstLine(filepath: string, firstLine?: string): string;
4141
getModeId(commaSeparatedMimetypesOrCommaSeparatedIds: string): string;
4242
getLanguageIdentifier(modeId: string | LanguageId): LanguageIdentifier;
4343
getConfigurationFiles(modeId: string): URI[];
@@ -46,5 +46,5 @@ export interface IModeService {
4646
getMode(commaSeparatedMimetypesOrCommaSeparatedIds: string): IMode;
4747
getOrCreateMode(commaSeparatedMimetypesOrCommaSeparatedIds: string): TPromise<IMode>;
4848
getOrCreateModeByLanguageName(languageName: string): TPromise<IMode>;
49-
getOrCreateModeByFilenameOrFirstLine(filepath: string, firstLine?: string): TPromise<IMode>;
49+
getOrCreateModeByFilepathOrFirstLine(filepath: string, firstLine?: string): TPromise<IMode>;
5050
}

src/vs/editor/common/services/modeServiceImpl.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ export class ModeServiceImpl implements IModeService {
6464
return this._registry.getModeIdForLanguageNameLowercase(alias);
6565
}
6666

67-
public getModeIdByFilenameOrFirstLine(filepath: string, firstLine?: string): string {
68-
const modeIds = this._registry.getModeIdsFromFilenameOrFirstLine(filepath, firstLine);
67+
public getModeIdByFilepathOrFirstLine(filepath: string, firstLine?: string): string {
68+
const modeIds = this._registry.getModeIdsFromFilepathOrFirstLine(filepath, firstLine);
6969

7070
if (modeIds.length > 0) {
7171
return modeIds[0];
@@ -142,9 +142,9 @@ export class ModeServiceImpl implements IModeService {
142142
return null;
143143
}
144144

145-
public getOrCreateModeByFilenameOrFirstLine(filepath: string, firstLine?: string): TPromise<IMode> {
145+
public getOrCreateModeByFilepathOrFirstLine(filepath: string, firstLine?: string): TPromise<IMode> {
146146
return this._onReady().then(() => {
147-
const modeId = this.getModeIdByFilenameOrFirstLine(filepath, firstLine);
147+
const modeId = this.getModeIdByFilepathOrFirstLine(filepath, firstLine);
148148
// Fall back to plain text if no mode was found
149149
return this._getOrCreateMode(modeId || 'plaintext');
150150
});

src/vs/editor/common/services/resourceConfigurationImpl.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export class TextResourceConfigurationService extends Disposable implements ITex
4242
if (model) {
4343
return position ? this.modeService.getLanguageIdentifier(model.getLanguageIdAtPosition(position.lineNumber, position.column)).language : model.getLanguageIdentifier().language;
4444
}
45-
return this.modeService.getModeIdByFilenameOrFirstLine(resource.path);
45+
return this.modeService.getModeIdByFilepathOrFirstLine(resource.path);
4646

4747
}
4848
}

src/vs/editor/contrib/goToDefinition/goToDefinitionMouse.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ class GotoDefinitionWithMouseEditorContribution implements editorCommon.IEditorC
157157

158158
this.addDecoration(
159159
wordRange,
160-
new MarkdownString().appendCodeblock(this.modeService.getModeIdByFilenameOrFirstLine(textEditorModel.uri.fsPath), previewValue)
160+
new MarkdownString().appendCodeblock(this.modeService.getModeIdByFilepathOrFirstLine(textEditorModel.uri.fsPath), previewValue)
161161
);
162162
ref.dispose();
163163
});

src/vs/editor/standalone/browser/standaloneEditor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ export function createModel(value: string, language?: string, uri?: URI): ITextM
157157
firstLine = value.substring(0, firstLF);
158158
}
159159

160-
return doCreateModel(value, StaticServices.modeService.get().getOrCreateModeByFilenameOrFirstLine(path, firstLine), uri);
160+
return doCreateModel(value, StaticServices.modeService.get().getOrCreateModeByFilepathOrFirstLine(path, firstLine), uri);
161161
}
162162
return doCreateModel(value, StaticServices.modeService.get().getOrCreateMode(language), uri);
163163
}

src/vs/workbench/api/electron-browser/mainThreadDocumentContentProviders.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export class MainThreadDocumentContentProviders implements MainThreadDocumentCon
4747
return this._proxy.$provideTextDocumentContent(handle, uri).then(value => {
4848
if (typeof value === 'string') {
4949
const firstLineText = value.substr(0, 1 + value.search(/\r?\n/));
50-
const mode = this._modeService.getOrCreateModeByFilenameOrFirstLine(uri.fsPath, firstLineText);
50+
const mode = this._modeService.getOrCreateModeByFilepathOrFirstLine(uri.fsPath, firstLineText);
5151
return this._modelService.createModel(value, mode, uri);
5252
}
5353
return undefined;

src/vs/workbench/browser/labels.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ export function getIconClasses(modelService: IModelService, modeService: IModeSe
350350

351351
// Configured Language
352352
let configuredLangId = getConfiguredLangId(modelService, resource);
353-
configuredLangId = configuredLangId || modeService.getModeIdByFilenameOrFirstLine(path);
353+
configuredLangId = configuredLangId || modeService.getModeIdByFilepathOrFirstLine(path);
354354
if (configuredLangId) {
355355
classes.push(`${cssEscape(configuredLangId)}-lang-file-icon`);
356356
}

src/vs/workbench/browser/parts/editor/editor.contribution.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
4949
import { isMacintosh } from 'vs/base/common/platform';
5050
import { AllEditorsPicker, ActiveEditorGroupPicker } from 'vs/workbench/browser/parts/editor/editorPicker';
5151
import { Schemas } from 'vs/base/common/network';
52+
import { registerEditorContribution } from 'vs/editor/browser/editorExtensions';
53+
import { OpenWorkspaceButtonContribution } from 'vs/workbench/browser/parts/editor/editorWidgets';
5254

5355
// Register String Editor
5456
Registry.as<IEditorRegistry>(EditorExtensions.Editors).registerEditor(
@@ -213,6 +215,9 @@ class SideBySideEditorInputFactory implements IEditorInputFactory {
213215

214216
Registry.as<IEditorInputFactoryRegistry>(EditorInputExtensions.EditorInputFactories).registerEditorInputFactory(SideBySideEditorInput.ID, SideBySideEditorInputFactory);
215217

218+
// Register Editor Contributions
219+
registerEditorContribution(OpenWorkspaceButtonContribution);
220+
216221
// Register Editor Status
217222
const statusBar = Registry.as<IStatusbarRegistry>(StatusExtensions.Statusbar);
218223
statusBar.registerStatusbarItem(new StatusbarItemDescriptor(EditorStatus, StatusbarAlignment.RIGHT, 100 /* towards the left of the right hand side */));

0 commit comments

Comments
 (0)