-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix a regression in hide functionality
- Loading branch information
Showing
20 changed files
with
123 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
@forward "./base" hide $color-white; |
3 changes: 3 additions & 0 deletions
3
fixtures/unit/completion/multi-level-hide/colors/base/_base.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
$color-black: black; | ||
$color-grey: grey; | ||
$color-white: white; |
1 change: 1 addition & 0 deletions
1
fixtures/unit/completion/multi-level-hide/colors/base/_index.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
@forward "./base" hide $color-black; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
@use "./colors"; | ||
|
||
$text-color: colors.| |
2 changes: 2 additions & 0 deletions
2
fixtures/unit/completion/same-symbol-name-hide/colors/_index.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
@forward "./branch-a" hide $color-white; | ||
@forward "./branch-b"; |
1 change: 1 addition & 0 deletions
1
fixtures/unit/completion/same-symbol-name-hide/colors/branch-a/_base.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
$color-white: white; |
1 change: 1 addition & 0 deletions
1
fixtures/unit/completion/same-symbol-name-hide/colors/branch-a/_index.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
@forward "./base"; |
1 change: 1 addition & 0 deletions
1
fixtures/unit/completion/same-symbol-name-hide/colors/branch-b/_base.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
$color-white: white; |
1 change: 1 addition & 0 deletions
1
fixtures/unit/completion/same-symbol-name-hide/colors/branch-b/_index.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
@forward "./base"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
@use "./colors"; | ||
|
||
$text-color: colors.| |
2 changes: 2 additions & 0 deletions
2
fixtures/unit/completion/same-symbol-name-show/colors/_index.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
@forward "./branch-a" show $color-black; | ||
@forward "./branch-b"; |
3 changes: 3 additions & 0 deletions
3
fixtures/unit/completion/same-symbol-name-show/colors/branch-a/_base.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
$color-black: black; | ||
$color-grey: grey; | ||
$color-white: white; |
1 change: 1 addition & 0 deletions
1
fixtures/unit/completion/same-symbol-name-show/colors/branch-a/_index.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
@forward "./base"; |
3 changes: 3 additions & 0 deletions
3
fixtures/unit/completion/same-symbol-name-show/colors/branch-b/_base.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
$color-black: black; | ||
$color-grey: grey; | ||
$color-white: white; |
1 change: 1 addition & 0 deletions
1
fixtures/unit/completion/same-symbol-name-show/colors/branch-b/_index.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
@forward "./base"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
@use "./colors"; | ||
|
||
$text-color: colors.| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import * as assert from "assert"; | ||
import { changeConfiguration, useContext } from "../../context-provider"; | ||
import { doCompletion } from "../../features/completion"; | ||
import { NodeFileSystem } from "../../node-file-system"; | ||
import { IScssDocument } from "../../parser"; | ||
import ScannerService from "../../scanner"; | ||
import { getUri } from "../fixture-helper"; | ||
import * as helpers from "../helpers"; | ||
|
||
describe("Providers/Completion", () => { | ||
beforeEach(async () => { | ||
helpers.createTestContext(new NodeFileSystem()); | ||
|
||
const settings = helpers.makeSettings({ | ||
suggestFromUseOnly: true, | ||
}); | ||
changeConfiguration(settings); | ||
}); | ||
|
||
describe("Hide", () => { | ||
it("supports multi-level hiding", async () => { | ||
const workspaceUri = getUri("completion/multi-level-hide/"); | ||
const docUri = getUri("completion/multi-level-hide/styles.scss"); | ||
const scanner = new ScannerService(); | ||
await scanner.scan([docUri], workspaceUri); | ||
const { storage } = useContext(); | ||
const stylesDoc = storage.get(docUri) as IScssDocument; | ||
|
||
const completions = await doCompletion( | ||
stylesDoc, | ||
stylesDoc.getText().indexOf("|"), | ||
); | ||
|
||
// $color-black and $color-white are hidden at different points | ||
|
||
assert.equal( | ||
completions.items.length, | ||
1, | ||
"Expected only one suggestion from the multi-level-hide fixture", | ||
); | ||
assert.equal(completions.items[0].label, "$color-grey"); | ||
}); | ||
|
||
it("doesn't hide symbol with same name in different part of dependency graph", async () => { | ||
const workspaceUri = getUri("completion/same-symbol-name-hide/"); | ||
const docUri = getUri("completion/same-symbol-name-hide/styles.scss"); | ||
const scanner = new ScannerService(); | ||
await scanner.scan([docUri], workspaceUri); | ||
const { storage } = useContext(); | ||
const stylesDoc = storage.get(docUri) as IScssDocument; | ||
|
||
const completions = await doCompletion( | ||
stylesDoc, | ||
stylesDoc.getText().indexOf("|"), | ||
); | ||
|
||
// $color-white is hidden in branch-a, but not in branch-b | ||
assert.equal( | ||
completions.items.length, | ||
1, | ||
"Expected a suggestion from the same-symbol-name-hide fixture", | ||
); | ||
assert.equal(completions.items[0].label, "$color-white"); | ||
}); | ||
}); | ||
|
||
describe("Show", () => { | ||
it("doesn't show symbol with same name in different part of dependency graph", async () => { | ||
const workspaceUri = getUri("completion/same-symbol-name-show/"); | ||
const docUri = getUri("completion/same-symbol-name-show/styles.scss"); | ||
const scanner = new ScannerService(); | ||
await scanner.scan([docUri], workspaceUri); | ||
const { storage } = useContext(); | ||
const stylesDoc = storage.get(docUri) as IScssDocument; | ||
|
||
const completions = await doCompletion( | ||
stylesDoc, | ||
stylesDoc.getText().indexOf("|"), | ||
); | ||
|
||
// One branch only shows $color-black, but the other has three symbols including another $color-black | ||
assert.equal( | ||
completions.items.length, | ||
4, | ||
"Expected four suggestions from the same-symbol-name-show fixture", | ||
); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters