Skip to content

Commit

Permalink
Merge 2dba84a into 7d70145
Browse files Browse the repository at this point in the history
  • Loading branch information
EduardSergeev committed May 19, 2024
2 parents 7d70145 + 2dba84a commit 3c28f54
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 22 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ jobs:
node-version: 20

- name: Set up GHC environment
run: |
echo "resolver: ghc-9.4.5" > stack.yaml
echo "packages: []" >> stack.yaml
stack setup
run: stack setup

- run: npm install

Expand Down
13 changes: 11 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
# Change Log
All notable changes to the "Haskutil" extension will be documented in this file.

## [0.13.2] - 2024-05-19
### Fixed
* `Remove unused imports` action when import declaration contains elements with `(..)` ([#40](https://github.com/EduardSergeev/vscode-haskutil/issues/40)):
Fix behaviour of `RemoveUnusedImportProvider` in regards to removal from import lists containing elements with export lists, e.g. `Sum(..)` or `Sum(fromSum)`;
* `Replace wildcard` action under GHC 9.6.5 ([#79](https://github.com/EduardSergeev/vscode-haskutil/issues/79)):
Fix `TypeWildcardProvider` behavior when running with latest GHC handling changes in corresponding GHC error message format;
### Changed
* Switch `branch` CI build to run tests against the latest GHC

## [0.13.1] - 2024-05-11
### Fixed
* Intermittent test failures
Failures with "Cancelled" error message
* CHANELOG formatting
Failures with `Cancelled` error message
* `CHANELOG` formatting

## [0.13.0] - 2024-05-07
### Added
Expand Down
7 changes: 7 additions & 0 deletions input/after/UnusedImportProvider.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import Data.List (sort)
import Data.Monoid (Product(getProduct), Sum(..))

foo :: Ord a => [a] -> [a]
foo xs =
sort xs

sum :: Sum a -> a
sum = getSum

product :: Product a -> a
product = getProduct
7 changes: 7 additions & 0 deletions input/before/UnusedImportProvider.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import Data.List (sort, tails)
import Data.Maybe
import Data.Monoid (All(..), Any(getAny), Product(getProduct), Sum(..))

foo :: Ord a => [a] -> [a]
foo xs =
sort xs

sum :: Sum a -> a
sum = getSum

product :: Product a -> a
product = getProduct
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.13.1",
"version": "0.13.2",
"publisher": "Edka",
"icon": "images/Haskutil-logo.png",
"repository": {
Expand Down Expand Up @@ -256,7 +256,7 @@
"@istanbuljs/nyc-config-typescript": "1.0.2",
"@types/chai": "4.3.16",
"@types/mocha": "10.0.6",
"@types/node": "20.12.11",
"@types/node": "20.12.12",
"@types/vscode": "1.48.0",
"@vscode/vsce": "2.26.1",
"@vscode/test-electron": "2.3.9",
Expand Down
12 changes: 7 additions & 5 deletions src/features/importProvider/importDeclaration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,14 @@ export default class ImportDeclaration {

public removeElement(elem: string) {
const before = this.importElements;
const index = this.importNames.findIndex(oldElem => oldElem === elem);
this._importElements.splice(index, 1);
if(index === 0 && this._importElements.length > 0) {
this._importElements[0] = this._importElements[0].trimLeft();
const index = this.importNames.findIndex(oldElem => oldElem === elem || oldElem == `${elem}(..)`);
if (index !== -1) {
this._importElements.splice(index, 1);
if(index === 0 && this._importElements.length > 0) {
this._importElements[0] = this._importElements[0].trimStart();
}
this.importList = this.importList.replace(before, this.importElements);
}
this.importList = this.importList.replace(before, this.importElements);
}

public get text() {
Expand Down
2 changes: 1 addition & 1 deletion src/features/removeUnusedImportProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export default class RemoveUnusedImportProvider implements CodeActionProvider {
return diagnostics
.map(d => [
d.range,
d.message.match(/The (qualified )?import of (?:[`‘](.+?)['’]\s+from module )?[`‘](.+?)['’] is redundant/m)
d.message.match(/The (qualified )?import of (?:[`‘]([\s\S]+?)['’]\s+from module )?[`‘](.+?)['’] is redundant/m)
] as const)
.filter(([,m]) => m)
.map(([range, match]) => [
Expand Down
2 changes: 1 addition & 1 deletion src/features/typeWildcardProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default class TypeWildcardProvider implements CodeActionProvider {
}

const line = document.lineAt(diagnostic.range.start);
if(fill === "()") {
if(fill === "()" || fill == "() :: Constraint") {
fill = "";
const wilcardMatch = line.text.match(/_\s*=>\s*/) || line.text.match(/,\s*_\s*/) || line.text.match(/\s*_\s*,/);
if(wilcardMatch) {
Expand Down
2 changes: 1 addition & 1 deletion src/test/providers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ suite('', () => {
});

test('Remove unused imports', () => {
return runQuickfixTest('UnusedImportProvider.hs', 2);
return runQuickfixTest('UnusedImportProvider.hs', 3);
});

test('Add missing extension', () => {
Expand Down

0 comments on commit 3c28f54

Please sign in to comment.