Skip to content

Commit

Permalink
Various fixes
Browse files Browse the repository at this point in the history
- Fix:
  - `OrganizeExtensionProvider`: false positive of `Extension are unorganised`
    Aligned extension were incorrectly detected as being not aligned
  - `ImportProvider`: `Organize imports` behaviour on Windows
    Fix invalid parsing of imports in file with `\r\n` (Windows) line ending
    As a result applying `Organize imports` would previously lead to corrupted imports
  - Fail CI build in case of test failure:
    Previously build would still be green even if some of the test were failing
  • Loading branch information
EduardSergeev authored Aug 27, 2023
2 parents 5adcfad + 670f011 commit b770082
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 13 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ jobs:
with:
run: npm test

- name: Add GHC extension output (on failure on Linux)
if: failure() && runner.os == 'Linux'
- name: Add GHC extension output (on failure on Linux or MacOS)
if: failure() && runner.os != 'Windows'
run: find .vscode-test/udd/logs -name *GHC* -exec cat {} \;

- name: Add GHC extension output (on failure on Windows)
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
# Change Log
All notable changes to the "Haskutil" extension will be documented in this file.

## [0.11.4] - 2023-08-27
### Fixed
* `OrganizeExtensionProvider`: false positive of `Extension are unorganised`
Aligned extension were incorrectly detected as being not aligned
* `ImportProvider`: `Organize imports` behaviour on Windows
Fix invalid parsing of imports in file with `\r\n` (Windows) line ending
As a result applying `Organize imports` would previously lead to corrupted imports
* Fail CI build in case of test failure:
Previously build would still be green even if some of the test wer failing

## [0.11.3] - 2023-08-26
### Fixed
* `ImportProvider`:
Expand Down
12 changes: 6 additions & 6 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "haskutil",
"displayName": "Haskutil",
"description": "'QuickFix' actions for Haskell editor",
"version": "0.11.3",
"version": "0.11.4",
"publisher": "Edka",
"repository": {
"url": "https://github.com/EduardSergeev/vscode-haskutil"
Expand Down Expand Up @@ -225,7 +225,7 @@
"@types/vscode": "1.48.0",
"@vscode/vsce": "2.20.1",
"@vscode/test-electron": "2.3.4",
"chai": "4.3.7",
"chai": "4.3.8",
"mocha": "10.2.0",
"nyc": "15.1.0",
"source-map-support": "0.5.21",
Expand Down
2 changes: 1 addition & 1 deletion src/features/importProvider/importDeclaration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export default class ImportDeclaration {
}

public static getImports(text: string): ImportDeclaration[] {
const importPattern = /^import((?:\s+qualified\s+)|\s+)(\S+)(\s+as\s+(\S+))?(\s*?\(((?:(?:\(.*?\))|.|\n)*?)\))?(\s+hiding\s+\(((?:(?:\(.*?\))|.|\n)*?)\))?/gm;
const importPattern = /^import((?:\s+qualified\s+)|\s+)(\S+)(\s+as\s+(\S+))?(\s*?\(((?:(?:\(.*?\))|.|\r?\n)*?)\))?(\s+hiding\s+\(((?:(?:\(.*?\))|.|\r?\n)*?)\))?/gm;
const imports = [];
for (let match; match = importPattern.exec(text);) {
imports.push(new ImportDeclaration(
Expand Down
2 changes: 1 addition & 1 deletion src/features/organizeExtensionProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default class OrganizeExtensionProvider implements CodeActionProvider {
const aligned =
extensions.length === 0 ||
extensions.every(extension => extension.extensions.length === extensions[0].extensions.length) &&
Math.max(...extensions.map(extension => extension.extensions.trimEnd().length)) === extensions[0].extensions.length;
Math.max(...extensions.map(extension => extension.extensions.trimEnd().length + 1)) === extensions[0].extensions.length;
unorganized = unorganized || Configuration.shouldAlignExtensions && !aligned;

let pred = "";
Expand Down
5 changes: 4 additions & 1 deletion src/test/runTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ async function main(): Promise<number> {
});
}

// This is required for Mocha tests to report non-zero exit code in case of test failure
process.removeAllListeners('exit');

// Download VS Code, unzip it and run the integration test
return await runTests({
vscodeExecutablePath,
Expand All @@ -62,7 +65,7 @@ async function main(): Promise<number> {
} catch (err) {
console.error(err);
console.error('Failed to run tests');
return 1;
process.exit(1);
}
}

Expand Down

0 comments on commit b770082

Please sign in to comment.