Skip to content

Commit 39f8e2a

Browse files
committed
microsoft#103454 do not use deprecated methods
1 parent 8a06771 commit 39f8e2a

11 files changed

Lines changed: 19 additions & 27 deletions

File tree

src/vs/platform/extensionManagement/common/configRemotes.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import { URI } from 'vs/base/common/uri';
7-
import { endsWith } from 'vs/base/common/strings';
87

98
const SshProtocolMatcher = /^([^@:]+@)?([^:]+):/;
109
const SshUrlMatcher = /^([^@:]+@)?([^:]+):(.+)$/;
@@ -76,7 +75,7 @@ function stripPort(authority: string): string | null {
7675

7776
function normalizeRemote(host: string | null, path: string, stripEndingDotGit: boolean): string | null {
7877
if (host && path) {
79-
if (stripEndingDotGit && endsWith(path, '.git')) {
78+
if (stripEndingDotGit && path.endsWith('.git')) {
8079
path = path.substr(0, path.length - 4);
8180
}
8281
return (path.indexOf('/') === 0) ? `${host}${path}` : `${host}/${path}`;

src/vs/platform/userDataSync/common/keybindingsMerge.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import * as objects from 'vs/base/common/objects';
77
import { parse } from 'vs/base/common/json';
88
import { IUserFriendlyKeybinding } from 'vs/platform/keybinding/common/keybinding';
9-
import { firstIndex as findFirstIndex, equals } from 'vs/base/common/arrays';
9+
import { equals } from 'vs/base/common/arrays';
1010
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
1111
import * as contentUtil from 'vs/platform/userDataSync/common/content';
1212
import { IStringDictionary } from 'vs/base/common/collections';
@@ -346,7 +346,7 @@ function removeKeybindings(content: string, command: string, formattingOptions:
346346

347347
function updateKeybindings(content: string, command: string, keybindings: IUserFriendlyKeybinding[], formattingOptions: FormattingOptions): string {
348348
const allKeybindings = parseKeybindings(content);
349-
const location = findFirstIndex(allKeybindings, keybinding => keybinding.command === command || keybinding.command === `-${command}`);
349+
const location = allKeybindings.findIndex(keybinding => keybinding.command === command || keybinding.command === `-${command}`);
350350
// Remove all entries with this command
351351
for (let index = allKeybindings.length - 1; index >= 0; index--) {
352352
if (allKeybindings[index].command === command || allKeybindings[index].command === `-${command}`) {

src/vs/platform/userDataSync/common/settingsMerge.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { IStringDictionary } from 'vs/base/common/collections';
1010
import { FormattingOptions, Edit, getEOL } from 'vs/base/common/jsonFormatter';
1111
import * as contentUtil from 'vs/platform/userDataSync/common/content';
1212
import { IConflictSetting, getDisallowedIgnoredSettings } from 'vs/platform/userDataSync/common/userDataSync';
13-
import { firstIndex, distinct } from 'vs/base/common/arrays';
13+
import { distinct } from 'vs/base/common/arrays';
1414
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
1515

1616
export interface IMergeResult {
@@ -320,7 +320,7 @@ interface InsertLocation {
320320

321321
function getInsertLocation(key: string, sourceTree: INode[], targetTree: INode[]): InsertLocation {
322322

323-
const sourceNodeIndex = firstIndex(sourceTree, (node => node.setting?.key === key));
323+
const sourceNodeIndex = sourceTree.findIndex(node => node.setting?.key === key);
324324

325325
const sourcePreviousNode: INode = sourceTree[sourceNodeIndex - 1];
326326
if (sourcePreviousNode) {

src/vs/workbench/browser/parts/views/viewPaneContainer.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import { attachStyler, IColorMapping, attachButtonStyler, attachLinkStyler, atta
1111
import { SIDE_BAR_DRAG_AND_DROP_BACKGROUND, SIDE_BAR_SECTION_HEADER_FOREGROUND, SIDE_BAR_SECTION_HEADER_BACKGROUND, SIDE_BAR_SECTION_HEADER_BORDER, PANEL_BACKGROUND, SIDE_BAR_BACKGROUND, PANEL_SECTION_HEADER_FOREGROUND, PANEL_SECTION_HEADER_BACKGROUND, PANEL_SECTION_HEADER_BORDER, PANEL_SECTION_DRAG_AND_DROP_BACKGROUND, PANEL_SECTION_BORDER } from 'vs/workbench/common/theme';
1212
import { after, append, $, trackFocus, toggleClass, EventType, isAncestor, Dimension, addDisposableListener, removeClass, addClass, createCSSRule, asCSSUrl, addClasses } from 'vs/base/browser/dom';
1313
import { IDisposable, combinedDisposable, dispose, toDisposable, Disposable, DisposableStore } from 'vs/base/common/lifecycle';
14-
import { firstIndex } from 'vs/base/common/arrays';
1514
import { IAction, Separator, IActionViewItem } from 'vs/base/common/actions';
1615
import { ActionsOrientation, prepareActions } from 'vs/base/browser/ui/actionbar/actionbar';
1716
import { Registry } from 'vs/platform/registry/common/platform';
@@ -1581,7 +1580,7 @@ export class ViewPaneContainer extends Component implements IViewPaneContainer {
15811580
}
15821581

15831582
private removePane(pane: ViewPane): void {
1584-
const index = firstIndex(this.paneItems, i => i.pane === pane);
1583+
const index = this.paneItems.findIndex(i => i.pane === pane);
15851584

15861585
if (index === -1) {
15871586
return;
@@ -1598,8 +1597,8 @@ export class ViewPaneContainer extends Component implements IViewPaneContainer {
15981597
}
15991598

16001599
movePane(from: ViewPane, to: ViewPane): void {
1601-
const fromIndex = firstIndex(this.paneItems, item => item.pane === from);
1602-
const toIndex = firstIndex(this.paneItems, item => item.pane === to);
1600+
const fromIndex = this.paneItems.findIndex(item => item.pane === from);
1601+
const toIndex = this.paneItems.findIndex(item => item.pane === to);
16031602

16041603
const fromViewDescriptor = this.viewContainerModel.visibleViewDescriptors[fromIndex];
16051604
const toViewDescriptor = this.viewContainerModel.visibleViewDescriptors[toIndex];

src/vs/workbench/contrib/extensions/common/extensionsUtils.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import * as arrays from 'vs/base/common/arrays';
76
import { localize } from 'vs/nls';
87
import { Event } from 'vs/base/common/event';
98
import { onUnexpectedError } from 'vs/base/common/errors';
@@ -44,7 +43,7 @@ export class KeymapExtensions extends Disposable implements IWorkbenchContributi
4443
private checkForOtherKeymaps(extensionIdentifier: IExtensionIdentifier): Promise<void> {
4544
return this.instantiationService.invokeFunction(getInstalledExtensions).then(extensions => {
4645
const keymaps = extensions.filter(extension => isKeymapExtension(this.tipsService, extension));
47-
const extension = arrays.first(keymaps, extension => areSameExtensions(extension.identifier, extensionIdentifier));
46+
const extension = keymaps.find(extension => areSameExtensions(extension.identifier, extensionIdentifier));
4847
if (extension && extension.globallyEnabled) {
4948
const otherKeymaps = keymaps.filter(extension => !areSameExtensions(extension.identifier, extensionIdentifier) && extension.globallyEnabled);
5049
if (otherKeymaps.length) {

src/vs/workbench/contrib/localizations/browser/localizationsActions.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import { IJSONEditingService } from 'vs/workbench/services/configuration/common/
1212
import { IHostService } from 'vs/workbench/services/host/browser/host';
1313
import { INotificationService } from 'vs/platform/notification/common/notification';
1414
import { language } from 'vs/base/common/platform';
15-
import { firstIndex } from 'vs/base/common/arrays';
1615
import { IExtensionsViewPaneContainer, VIEWLET_ID as EXTENSIONS_VIEWLET_ID } from 'vs/workbench/contrib/extensions/common/extensions';
1716
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
1817
import { IDialogService } from 'vs/platform/dialogs/common/dialogs';
@@ -47,7 +46,7 @@ export class ConfigureLocaleAction extends Action {
4746

4847
public async run(): Promise<void> {
4948
const languageOptions = await this.getLanguageOptions();
50-
const currentLanguageIndex = firstIndex(languageOptions, l => l.label === language);
49+
const currentLanguageIndex = languageOptions.findIndex(l => l.label === language);
5150

5251
try {
5352
const selectedLanguage = await this.quickInputService.pick(languageOptions,

src/vs/workbench/contrib/preferences/browser/preferencesEditor.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import * as DOM from 'vs/base/browser/dom';
77
import { Orientation, Sizing, SplitView } from 'vs/base/browser/ui/splitview/splitview';
88
import { Widget } from 'vs/base/browser/ui/widget';
9-
import * as arrays from 'vs/base/common/arrays';
109
import { Delayer, ThrottledDelayer } from 'vs/base/common/async';
1110
import { CancellationToken, CancellationTokenSource } from 'vs/base/common/cancellation';
1211
import { IStringDictionary } from 'vs/base/common/collections';
@@ -646,7 +645,7 @@ class PreferencesRenderersController extends Disposable {
646645
const current = this._settingsNavigator && this._settingsNavigator.current();
647646
const navigatorSettings = this._lastQuery ? consolidatedSettings : [];
648647
const currentIndex = current ?
649-
arrays.firstIndex(navigatorSettings, s => s.key === current.key) :
648+
navigatorSettings.findIndex(s => s.key === current.key) :
650649
-1;
651650

652651
this._settingsNavigator = new SettingsNavigator(navigatorSettings, Math.max(currentIndex, 0));
@@ -691,7 +690,7 @@ class PreferencesRenderersController extends Disposable {
691690
if (nlpMetadata) {
692691
const sortedKeys = Object.keys(nlpMetadata.scoredResults).sort((a, b) => nlpMetadata.scoredResults[b].score - nlpMetadata.scoredResults[a].score);
693692
const suffix = '##' + key;
694-
data['nlpIndex'] = arrays.firstIndex(sortedKeys, key => key.endsWith(suffix));
693+
data['nlpIndex'] = sortedKeys.findIndex(key => key.endsWith(suffix));
695694
}
696695

697696
const settingLocation = this._findSetting(this.lastFilterResult, key);

src/vs/workbench/contrib/preferences/browser/preferencesRenderers.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ import { DefaultSettingsEditorModel, SettingsEditorModel, WorkspaceConfiguration
3131
import { IMarkerService, IMarkerData, MarkerSeverity, MarkerTag } from 'vs/platform/markers/common/markers';
3232
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
3333
import { EditorOption } from 'vs/editor/common/config/editorOptions';
34-
import { find } from 'vs/base/common/arrays';
3534

3635
export interface IPreferencesRenderer<T> extends IDisposable {
3736
readonly preferencesModel: IPreferencesEditorModel<T>;
@@ -321,7 +320,7 @@ export class DefaultSettingsRenderer extends Disposable implements IPreferencesR
321320
const { key, overrideOf } = setting;
322321
if (overrideOf) {
323322
const setting = this.getSetting(overrideOf);
324-
return find(setting!.overrides!, override => override.key === key);
323+
return setting!.overrides!.find(override => override.key === key);
325324
}
326325
const settingsGroups = this.filterResult ? this.filterResult.filteredGroups : this.preferencesModel.settingsGroups;
327326
return this.getPreference(key, settingsGroups);

src/vs/workbench/services/configuration/common/configurationEditingService.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import * as nls from 'vs/nls';
77
import { URI } from 'vs/base/common/uri';
88
import * as resources from 'vs/base/common/resources';
99
import * as json from 'vs/base/common/json';
10-
import * as strings from 'vs/base/common/strings';
1110
import { setProperty } from 'vs/base/common/jsonEdit';
1211
import { Queue } from 'vs/base/common/async';
1312
import { Edit } from 'vs/base/common/jsonFormatter';
@@ -426,7 +425,7 @@ export class ConfigurationEditingService {
426425

427426
// Without jsonPath, the entire configuration file is being replaced, so we just use JSON.stringify
428427
if (!jsonPath.length) {
429-
const content = JSON.stringify(value, null, insertSpaces ? strings.repeat(' ', tabSize) : '\t');
428+
const content = JSON.stringify(value, null, insertSpaces ? ' '.repeat(tabSize) : '\t');
430429
return [{
431430
content,
432431
length: model.getValue().length,

src/vs/workbench/services/configuration/common/jsonEditingService.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import * as nls from 'vs/nls';
77
import { URI } from 'vs/base/common/uri';
88
import * as json from 'vs/base/common/json';
9-
import * as strings from 'vs/base/common/strings';
109
import { setProperty } from 'vs/base/common/jsonEdit';
1110
import { Queue } from 'vs/base/common/async';
1211
import { Edit } from 'vs/base/common/jsonFormatter';
@@ -79,7 +78,7 @@ export class JSONEditingService implements IJSONEditingService {
7978

8079
// With empty path the entire file is being replaced, so we just use JSON.stringify
8180
if (!path.length) {
82-
const content = JSON.stringify(value, null, insertSpaces ? strings.repeat(' ', tabSize) : '\t');
81+
const content = JSON.stringify(value, null, insertSpaces ? ' '.repeat(tabSize) : '\t');
8382
return [{
8483
content,
8584
length: content.length,

0 commit comments

Comments
 (0)