diff --git a/src/extension/extension.ts b/src/extension/extension.ts index 553f7c0a..09650738 100644 --- a/src/extension/extension.ts +++ b/src/extension/extension.ts @@ -16,7 +16,6 @@ import { randomName } from '../common/names'; import * as localize from '../common/localize'; import { availableColors, normalizeColor } from '../panel/pets'; - const EXTRA_PETS_KEY = 'vscode-pets.extra-pets'; const EXTRA_PETS_KEY_TYPES = EXTRA_PETS_KEY + '.types'; const EXTRA_PETS_KEY_COLORS = EXTRA_PETS_KEY + '.colors'; @@ -38,7 +37,6 @@ class PetQuickPickItem implements vscode.QuickPickItem { this.label = name_; this.description = `${color} ${type}`; this.petId = petId; - } name: string; @@ -114,7 +112,7 @@ export class PetSpecification { this.color = color; this.type = type; this.size = size; - + if (!name) { this.name = randomName(type); } else { @@ -209,14 +207,13 @@ async function handleRemovePetMessage( var petList: IPetInfo[] = Array(); switch (message.command) { case 'list-pets': - message.text.split('\n').forEach((pet) => { var parts = pet.split(','); petList.push({ type: parts[0] as PetType, name: parts[1], color: parts[2] as PetColor, - petId: Number(parts[3]) + petId: Number(parts[3]), }); }); break; @@ -229,7 +226,12 @@ async function handleRemovePetMessage( await vscode.window .showQuickPick( petList.map((val) => { - return new PetQuickPickItem(val.name, val.type, val.color, val.petId); + return new PetQuickPickItem( + val.name, + val.type, + val.color, + val.petId, + ); }), { placeHolder: vscode.l10n.t('Select the pet to remove.'), @@ -799,7 +801,7 @@ class PetWebviewContainer implements IPetPanel { this.getWebview().postMessage({ command: 'delete-pet', name: petName, - petId: petId + petId: petId, }); } @@ -978,8 +980,11 @@ class PetPanel extends PetWebviewContainer implements IPetPanel { } public deletePet(petName: string, petId: number): void { - this.getWebview().postMessage({ command: 'delete-pet', name: petName, petId: petId}); - + this.getWebview().postMessage({ + command: 'delete-pet', + name: petName, + petId: petId, + }); } public static revive( diff --git a/src/panel/basepettype.ts b/src/panel/basepettype.ts index 6ac35d59..09d1ce3f 100644 --- a/src/panel/basepettype.ts +++ b/src/panel/basepettype.ts @@ -68,9 +68,9 @@ export abstract class BasePetType implements IPetType { this._size = size; this._speed = this.randomizeSpeed(speed); - //increment petId: unique identifier for all pets + //increment petId: unique identifier for all pets this.petId = ++BasePetType.idMaker; - + // Increment the static count of the Pet class that the constructor belongs to (this.constructor as any).count += 1; } diff --git a/src/panel/main.ts b/src/panel/main.ts index 7261366d..3d9eb0f2 100644 --- a/src/panel/main.ts +++ b/src/panel/main.ts @@ -559,7 +559,8 @@ export function petPanelApp( command: 'list-pets', text: pets .map( - (pet) => `${pet.type},${pet.pet.name},${pet.color},${pet.pet.petId}`, + (pet) => + `${pet.type},${pet.pet.name},${pet.color},${pet.pet.petId}`, ) .join('\n'), }); diff --git a/src/panel/pets.ts b/src/panel/pets.ts index 8fc4018a..232e4af6 100644 --- a/src/panel/pets.ts +++ b/src/panel/pets.ts @@ -38,7 +38,6 @@ export class PetElement { pet: IPetType, color: PetColor, type: PetType, - ) { this.el = el; this.collision = collision; @@ -89,7 +88,6 @@ export class PetCollection implements IPetCollection { remove(id: number): any { this._pets.forEach((pet) => { - if (pet.pet.petId === id) { pet.remove(); }