Skip to content

Commit

Permalink
Fix operator import
Browse files Browse the repository at this point in the history
- Do not add `(..)` when adding import for operators
  • Loading branch information
EduardSergeev committed Aug 26, 2023
2 parents fc0ce08 + 6aa7151 commit 5adcfad
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 6 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
# Change Log
All notable changes to the "Haskutil" extension will be documented in this file.

## [0.11.3] - 2023-08-26
### Fixed
* `ImportProvider`:
Do not add `(..)` when adding import for operators

## [0.11.2] - 2023-08-26
### Fixed
* `OrganizeExtensionProvider`:
Make sure all `LANGUAGE` extension are aligning using minimal padding
Fixes [#41](https://github.com/EduardSergeev/vscode-haskutil/issues/41)
- `ImportProvider`:
* `ImportProvider`:
Suggest adding class or data type with `(..)`, i.e. with all defined constructors/members
Fixes [#44](https://github.com/EduardSergeev/vscode-haskutil/issues/41)

Expand Down
5 changes: 5 additions & 0 deletions input/after/ImportProvider.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import Control.Arrow ((>>>))
import Data.List (sort, tails)
import Data.Maybe

foo :: Ord a => [a] -> Maybe [a]
foo xs =
listToMaybe . tails. sort $ xs

bar :: (a -> b) -> (b -> c) -> (a -> c)
bar f g =
f >>> g
4 changes: 4 additions & 0 deletions input/before/ImportProvider.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@
foo :: Ord a => [a] -> Maybe [a]
foo xs =
listToMaybe . tails. sort $ xs

bar :: (a -> b) -> (b -> c) -> (a -> c)
bar f g =
f >>> g
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion 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.2",
"version": "0.11.3",
"publisher": "Edka",
"repository": {
"url": "https://github.com/EduardSergeev/vscode-haskutil"
Expand Down
2 changes: 1 addition & 1 deletion src/features/importProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export default class ImportProvider extends ImportProviderBase implements CodeAc
codeAction.diagnostics = [diagnostic];
codeActions.set(title, codeAction);

const element = variableName[0] === variableName[0].toUpperCase() ? `${variableName}(..)` : variableName;
const element = variableName[0] === variableName[0].toLowerCase() ? variableName : `${variableName}(..)`;
title = `Add: "import ${result.module} (${element})"`;
codeAction = new CodeAction(title, CodeActionKind.QuickFix);
codeAction.command = {
Expand Down
3 changes: 2 additions & 1 deletion src/test/providers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ suite('', () => {
});

test('Add missing import', () => {
return runQuickfixTest('ImportProvider.hs', 3,
return runQuickfixTest('ImportProvider.hs', 4,
'Add: "import Control.Arrow ((>>>))"',
'Add: "import Data.Maybe"',
'Add: "import Data.List (tails)"',
'Add: "import Data.List (sort)"',
Expand Down

0 comments on commit 5adcfad

Please sign in to comment.