Skip to content

Commit

Permalink
Fix block style v2 formatting (#552)
Browse files Browse the repository at this point in the history
  • Loading branch information
mark-wiemer authored Oct 19, 2024
1 parent f0f75c7 commit c92377f
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 121 deletions.
2 changes: 1 addition & 1 deletion ahk2
Submodule ahk2 updated from 234ebd to c05e25
5 changes: 3 additions & 2 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@

### Fixes

- Fix v1 formatter removing extra spaces in strings ([#411](https://github.com/mark-wiemer-org/ahkpp/issues/411))
- Fix v2 formatter moving closing brackets/braces when `arrayStyle` or `objectStyle` were set to "none" (the default) ([#499](https://github.com/mark-wiemer-org/ahkpp/issues/499))
- Fixup output channel names: "AHK++ (v1)" and "AHK++ (v2)" instead of "AHK" and "AHK++" respectively
- Fix duplicate output channels
- Fix formatter removing extra spaces in v1 strings ([#411](https://github.com/mark-wiemer-org/ahkpp/issues/411))
- Fix duplicate output channels (the "AHK" channel used to be created twice)

### Other

Expand Down
111 changes: 6 additions & 105 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,15 @@
"sort-package-json": "sort-package-json --check",
"sort-package-json:fix": "sort-package-json",
"test": "npm run test:grammar && npm run test:unit && npm run test:e2e",
"test:ci": "npm run test:grammar && npm run test:e2e:ci",
"test:ci": "npm run test:grammar && npm run test:unit:ci && npm run test:e2e:ci",
"pretest:e2e": "npm run build && npm run compile:ts",
"test:e2e": "vscode-test",
"test:e2e:ci": "npm run test:e2e -- -i --fgrep @ignoreCI",
"test:e2e:ci": "npm run test:e2e -- -i --fgrep @ignoreCI --forbid-only",
"pretest:grammar": "npm run compile:grammar",
"test:grammar": "vscode-tmgrammar-snap language/samples/*.{ahk1,ahk2}",
"pretest:unit": "npm run compile:ts",
"test:unit": "mocha",
"test:unit:ci": "npm run test:unit -- --forbid-only",
"validate": "npm run lint && npm run test && npm run package",
"validate:ci": "npm run lint && npm run test:ci && npm run package",
"validate:deep": "cd ahk2 && npm run validate && cd .. && npm run validate",
Expand Down Expand Up @@ -1158,7 +1159,6 @@
"devDependencies": {
"@eslint/js": "^9.9.0",
"@types/eslint__js": "^8.42.3",
"@types/fs-extra": "^9.0.7",
"@types/glob": "^7.1.3",
"@types/mocha": "^10.0.8",
"@types/node": "^20.16.0",
Expand All @@ -1171,7 +1171,6 @@
"del-cli": "^6.0.0",
"esbuild": "0.24.0",
"eslint": "^9.9.0",
"fs-extra": "^9.1.0",
"glob": "^7.1.6",
"js-yaml": "^4.1.0",
"mocha": "^10.0.0",
Expand Down
2 changes: 1 addition & 1 deletion src/providers/formattingProvider.e2e.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { getDocument, showDocument } from '../test/utils';
import * as assert from 'assert';
import * as fs from 'fs-extra';
import * as fs from 'fs';
import * as path from 'path';
import * as vscode from 'vscode';
import { FormatProvider } from './formattingProvider';
Expand Down
8 changes: 4 additions & 4 deletions src/providers/formattingProvider.utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
removeEmptyLines,
trimExtraSpaces,
} from './formattingProvider.utils';
import * as fs from 'fs-extra';
import * as fs from 'fs';
import * as path from 'path';
import { FormatOptions } from './formattingProvider.types';

Expand Down Expand Up @@ -1049,7 +1049,7 @@ interface FormatTest {
options?: Partial<FormatOptions>;
}

suite.only('internalFormat', () => {
suite('internalFormat', () => {
// Currently in `out` folder, need to get back to main `src` folder
const filesParentPath = path.join(
__dirname, // ./out/src/providers
Expand All @@ -1064,8 +1064,8 @@ suite.only('internalFormat', () => {
const inFilenameSuffix = '.in.ahk';
const outFilenameSuffix = '.out.ahk';

const fileToString = (path: string): string =>
fs.readFileSync(path).toString();
const fileToString = (filePath: string): string =>
fs.readFileSync(filePath).toString();

/** Default formatting options, meant to match default extension settings */
const defaultOptions = {
Expand Down
8 changes: 5 additions & 3 deletions src/test/config.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,13 @@ suite('exclude', () => {

tests.forEach(([name, version, exclude, expected]) => {
test(name, async () => {
if (version === 1)
if (version === 1) {
await updateConfig<string[]>(ConfigKey.exclude, exclude);
}
const filePath = resolve(rootPath, `./e2e/main.ahk${version}`);
const doc = await getDocument(filePath);
const editor = await showDocument(doc);
await sleep(1_000); // todo only these tests are extra flaky
await addAndSelectSnippet(editor, snippetText);

const labels = await getCompletionSuggestionLabels(editor);
Expand All @@ -99,14 +101,14 @@ suite('exclude', () => {
});
});

suite.only('v2.general.librarySuggestions', () => {
suite('v2.general.librarySuggestions', () => {
let editor: vscode.TextEditor;
before(async () => {
await updateConfig<string[]>(ConfigKey.exclude, []);
const filePath = resolve(rootPath, './e2e/main.ahk2');
const doc = await getDocument(filePath);
editor = await showDocument(doc);
await sleep(1000);
await sleep(1_000);
});

const tests: [name: string, libType: LibIncludeType, expected: boolean][] =
Expand Down
2 changes: 1 addition & 1 deletion src/test/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export const updateConfig = async <T>(
await vscode.workspace
.getConfiguration(configPrefix)
.update(section, value, false);
await sleep(1500); // todo tests are flaky even at 1_000ms
await sleep(1_500); // todo tests are flaky even at 1_000ms
};

/**
Expand Down

0 comments on commit c92377f

Please sign in to comment.