Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/core/commandRunner/CommandRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Graph, ProcessedTargetsContext } from "../../typings/Types";
import { isString } from "../../util/type";
import { canonicalizeAndValidateCommand } from "../commandVersionUpgrades/canonicalizeAndValidateCommand";
import { PartialTargetV0V1 } from "../commandVersionUpgrades/upgradeV1ToV2/commandV1.types";
import { DEFAULT_TAB_SIZE_FOR_TESTS } from "../constants";
import inferFullTargets from "../inferFullTargets";
import { ThatMark } from "../ThatMark";
import { Command } from "./command.types";
Expand Down Expand Up @@ -60,6 +61,10 @@ export default class CommandRunner {
if (this.graph.debug.active) {
this.graph.debug.log(`command:`);
this.graph.debug.log(JSON.stringify(command, null, 3));
if (vscode.window.activeTextEditor) {
vscode.window.activeTextEditor.options.tabSize =
DEFAULT_TAB_SIZE_FOR_TESTS;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm maybe we should only do this if they're recording a test? Otherwise we'll clobber their tab size if they have cursorless debug mode on

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heyo @pokey — I moved this entire step into the TestCaseRecorder since we have state there about whether we should or should not set the tabs. That also bring the code out of the CommandRunner loop. We clean up at the end and reset to the original tab setting, if a user stops recording their test.

}

const commandComplete = canonicalizeAndValidateCommand(command);
Expand Down
2 changes: 2 additions & 0 deletions src/core/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,5 @@ export interface HatStyle {
color: HatColor;
shape: HatShape;
}

export const DEFAULT_TAB_SIZE_FOR_TESTS = 4 as const;
3 changes: 3 additions & 0 deletions src/test/suite/recorded.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { promises as fsp } from "fs";
import * as yaml from "js-yaml";
import * as sinon from "sinon";
import * as vscode from "vscode";
import { DEFAULT_TAB_SIZE_FOR_TESTS } from "../../core/constants";
import HatTokenMap from "../../core/HatTokenMap";
import { ReadOnlyHatMap } from "../../core/IndividualHatMap";
import { extractTargetedMarks } from "../../testUtil/extractTargetedMarks";
Expand Down Expand Up @@ -75,6 +76,8 @@ async function runTest(file: string) {
fixture.initialState.documentContents,
fixture.languageId
);
// Override any user defaults, all tests are recorded as tabSize = 4
editor.options.tabSize = DEFAULT_TAB_SIZE_FOR_TESTS;

if (fixture.postEditorOpenSleepTimeMs != null) {
await sleep(fixture.postEditorOpenSleepTimeMs);
Expand Down