Skip to content

Commit 3dac12c

Browse files
committed
Normalize relative paths by avoiding prefixes of the form ./something.
1 parent 975b3d2 commit 3dac12c

File tree

4 files changed

+38
-36
lines changed

4 files changed

+38
-36
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
## master
2+
- Fix issue where using paths of the form `./something` would show multiple copies of the same file in vscode.
23

34
## 1.2.1
45

analysis/src/Files.ml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,9 @@ let relpath base path =
1919
if pathStartsWith path base then
2020
let baselen = String.length base in
2121
let rest = String.sub path baselen (String.length path - baselen) in
22-
if rest = "" then "." ^ Filename.dir_sep
23-
else if rest.[0] = Filename.dir_sep.[0] then
24-
if String.length rest > 1 && rest.[1] = '.' then sliceToEnd rest 1
25-
else "." ^ rest
26-
else if rest.[0] = '.' then rest
27-
else "." ^ Filename.dir_sep ^ rest
22+
(if rest <> "" && rest.[0] = Filename.dir_sep.[0] then sliceToEnd rest 1
23+
else rest)
24+
|> removeExtraDots
2825
else
2926
let rec loop bp pp =
3027
match (bp, pp) with
@@ -57,7 +54,6 @@ let readFile ~filename =
5754
with _ -> None
5855

5956
let exists path = match maybeStat path with None -> false | Some _ -> true
60-
6157
let ifExists path = if exists path then Some path else None
6258

6359
let readDirectory dir =

analysis/tests/bsconfig.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
{
22
"name": "test",
3-
"sources": "src",
3+
"sources": [
4+
{
5+
"dir": "src",
6+
"subdirs": true
7+
}
8+
],
49
"bs-dependencies": ["@rescript/react"],
510
"reason": { "react-jsx": 3 }
611
}

analysis/tests/src/expected/Debug.res.txt

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
11

22
Definition tests/src/Debug.res 1:20
33
Dependencies: @rescript/react
4-
Source directories: tests/node_modules/@rescript/react/./src tests/node_modules/@rescript/react/./src/legacy
5-
Source files: tests/node_modules/@rescript/react/./src/React.res tests/node_modules/@rescript/react/./src/ReactDOM.res tests/node_modules/@rescript/react/./src/ReactDOMServer.res tests/node_modules/@rescript/react/./src/ReactDOMStyle.res tests/node_modules/@rescript/react/./src/ReactEvent.res tests/node_modules/@rescript/react/./src/ReactEvent.resi tests/node_modules/@rescript/react/./src/ReactTestUtils.res tests/node_modules/@rescript/react/./src/ReactTestUtils.resi tests/node_modules/@rescript/react/./src/RescriptReactErrorBoundary.res tests/node_modules/@rescript/react/./src/RescriptReactErrorBoundary.resi tests/node_modules/@rescript/react/./src/RescriptReactRouter.res tests/node_modules/@rescript/react/./src/RescriptReactRouter.resi tests/node_modules/@rescript/react/./src/legacy/ReactDOMRe.res tests/node_modules/@rescript/react/./src/legacy/ReasonReact.res
6-
Source directories: tests/src
4+
Source directories: tests/node_modules/@rescript/react/src tests/node_modules/@rescript/react/src/legacy
5+
Source files: tests/node_modules/@rescript/react/src/React.res tests/node_modules/@rescript/react/src/ReactDOM.res tests/node_modules/@rescript/react/src/ReactDOMServer.res tests/node_modules/@rescript/react/src/ReactDOMStyle.res tests/node_modules/@rescript/react/src/ReactEvent.res tests/node_modules/@rescript/react/src/ReactEvent.resi tests/node_modules/@rescript/react/src/ReactTestUtils.res tests/node_modules/@rescript/react/src/ReactTestUtils.resi tests/node_modules/@rescript/react/src/RescriptReactErrorBoundary.res tests/node_modules/@rescript/react/src/RescriptReactErrorBoundary.resi tests/node_modules/@rescript/react/src/RescriptReactRouter.res tests/node_modules/@rescript/react/src/RescriptReactRouter.resi tests/node_modules/@rescript/react/src/legacy/ReactDOMRe.res tests/node_modules/@rescript/react/src/legacy/ReasonReact.res
6+
Source directories: tests/src tests/src/expected
77
Source files: tests/src/Auto.res tests/src/CompletePrioritize1.res tests/src/CompletePrioritize2.res tests/src/Completion.res tests/src/Component.res tests/src/Component.resi tests/src/Cross.res tests/src/Debug.res tests/src/Definition.res tests/src/DefinitionWithInterface.res tests/src/DefinitionWithInterface.resi tests/src/Div.res tests/src/Fragment.res tests/src/Hover.res tests/src/Jsx.res tests/src/Jsx.resi tests/src/LongIdentTest.res tests/src/Obj.res tests/src/Patterns.res tests/src/RecModules.res tests/src/RecordCompletion.res tests/src/References.res tests/src/ReferencesWithInterface.res tests/src/ReferencesWithInterface.resi tests/src/Rename.res tests/src/RenameWithInterface.res tests/src/RenameWithInterface.resi tests/src/TableclothMap.ml tests/src/TableclothMap.mli tests/src/TypeDefinition.res
8-
Impl cmt:tests/lib/bs/./src/Auto.cmt res:tests/src/Auto.res
9-
Impl cmt:tests/lib/bs/./src/CompletePrioritize1.cmt res:tests/src/CompletePrioritize1.res
10-
Impl cmt:tests/lib/bs/./src/CompletePrioritize2.cmt res:tests/src/CompletePrioritize2.res
11-
Impl cmt:tests/lib/bs/./src/Completion.cmt res:tests/src/Completion.res
12-
IntfAndImpl cmti:tests/lib/bs/./src/Component.cmti resi:tests/src/Component.resi cmt:tests/lib/bs/./src/Component.cmt res:tests/src/Component.res
13-
Impl cmt:tests/lib/bs/./src/Cross.cmt res:tests/src/Cross.res
14-
Impl cmt:tests/lib/bs/./src/Debug.cmt res:tests/src/Debug.res
15-
Impl cmt:tests/lib/bs/./src/Definition.cmt res:tests/src/Definition.res
16-
IntfAndImpl cmti:tests/lib/bs/./src/DefinitionWithInterface.cmti resi:tests/src/DefinitionWithInterface.resi cmt:tests/lib/bs/./src/DefinitionWithInterface.cmt res:tests/src/DefinitionWithInterface.res
17-
Impl cmt:tests/lib/bs/./src/Div.cmt res:tests/src/Div.res
18-
Impl cmt:tests/lib/bs/./src/Fragment.cmt res:tests/src/Fragment.res
19-
Impl cmt:tests/lib/bs/./src/Hover.cmt res:tests/src/Hover.res
20-
IntfAndImpl cmti:tests/lib/bs/./src/Jsx.cmti resi:tests/src/Jsx.resi cmt:tests/lib/bs/./src/Jsx.cmt res:tests/src/Jsx.res
21-
Impl cmt:tests/lib/bs/./src/LongIdentTest.cmt res:tests/src/LongIdentTest.res
22-
Impl cmt:tests/lib/bs/./src/Obj.cmt res:tests/src/Obj.res
23-
Impl cmt:tests/lib/bs/./src/Patterns.cmt res:tests/src/Patterns.res
24-
Impl cmt:tests/lib/bs/./src/RecModules.cmt res:tests/src/RecModules.res
25-
Impl cmt:tests/lib/bs/./src/RecordCompletion.cmt res:tests/src/RecordCompletion.res
26-
Impl cmt:tests/lib/bs/./src/References.cmt res:tests/src/References.res
27-
IntfAndImpl cmti:tests/lib/bs/./src/ReferencesWithInterface.cmti resi:tests/src/ReferencesWithInterface.resi cmt:tests/lib/bs/./src/ReferencesWithInterface.cmt res:tests/src/ReferencesWithInterface.res
28-
Impl cmt:tests/lib/bs/./src/Rename.cmt res:tests/src/Rename.res
29-
IntfAndImpl cmti:tests/lib/bs/./src/RenameWithInterface.cmti resi:tests/src/RenameWithInterface.resi cmt:tests/lib/bs/./src/RenameWithInterface.cmt res:tests/src/RenameWithInterface.res
30-
IntfAndImpl cmti:tests/lib/bs/./src/TableclothMap.cmti resi:tests/src/TableclothMap.mli cmt:tests/lib/bs/./src/TableclothMap.cmt res:tests/src/TableclothMap.ml
31-
Impl cmt:tests/lib/bs/./src/TypeDefinition.cmt res:tests/src/TypeDefinition.res
32-
Dependency dirs: tests/node_modules/@rescript/react/lib/bs/./src tests/node_modules/@rescript/react/lib/bs/./src/legacy
8+
Impl cmt:tests/lib/bs/src/Auto.cmt res:tests/src/Auto.res
9+
Impl cmt:tests/lib/bs/src/CompletePrioritize1.cmt res:tests/src/CompletePrioritize1.res
10+
Impl cmt:tests/lib/bs/src/CompletePrioritize2.cmt res:tests/src/CompletePrioritize2.res
11+
Impl cmt:tests/lib/bs/src/Completion.cmt res:tests/src/Completion.res
12+
IntfAndImpl cmti:tests/lib/bs/src/Component.cmti resi:tests/src/Component.resi cmt:tests/lib/bs/src/Component.cmt res:tests/src/Component.res
13+
Impl cmt:tests/lib/bs/src/Cross.cmt res:tests/src/Cross.res
14+
Impl cmt:tests/lib/bs/src/Debug.cmt res:tests/src/Debug.res
15+
Impl cmt:tests/lib/bs/src/Definition.cmt res:tests/src/Definition.res
16+
IntfAndImpl cmti:tests/lib/bs/src/DefinitionWithInterface.cmti resi:tests/src/DefinitionWithInterface.resi cmt:tests/lib/bs/src/DefinitionWithInterface.cmt res:tests/src/DefinitionWithInterface.res
17+
Impl cmt:tests/lib/bs/src/Div.cmt res:tests/src/Div.res
18+
Impl cmt:tests/lib/bs/src/Fragment.cmt res:tests/src/Fragment.res
19+
Impl cmt:tests/lib/bs/src/Hover.cmt res:tests/src/Hover.res
20+
IntfAndImpl cmti:tests/lib/bs/src/Jsx.cmti resi:tests/src/Jsx.resi cmt:tests/lib/bs/src/Jsx.cmt res:tests/src/Jsx.res
21+
Impl cmt:tests/lib/bs/src/LongIdentTest.cmt res:tests/src/LongIdentTest.res
22+
Impl cmt:tests/lib/bs/src/Obj.cmt res:tests/src/Obj.res
23+
Impl cmt:tests/lib/bs/src/Patterns.cmt res:tests/src/Patterns.res
24+
Impl cmt:tests/lib/bs/src/RecModules.cmt res:tests/src/RecModules.res
25+
Impl cmt:tests/lib/bs/src/RecordCompletion.cmt res:tests/src/RecordCompletion.res
26+
Impl cmt:tests/lib/bs/src/References.cmt res:tests/src/References.res
27+
IntfAndImpl cmti:tests/lib/bs/src/ReferencesWithInterface.cmti resi:tests/src/ReferencesWithInterface.resi cmt:tests/lib/bs/src/ReferencesWithInterface.cmt res:tests/src/ReferencesWithInterface.res
28+
Impl cmt:tests/lib/bs/src/Rename.cmt res:tests/src/Rename.res
29+
IntfAndImpl cmti:tests/lib/bs/src/RenameWithInterface.cmti resi:tests/src/RenameWithInterface.resi cmt:tests/lib/bs/src/RenameWithInterface.cmt res:tests/src/RenameWithInterface.res
30+
IntfAndImpl cmti:tests/lib/bs/src/TableclothMap.cmti resi:tests/src/TableclothMap.mli cmt:tests/lib/bs/src/TableclothMap.cmt res:tests/src/TableclothMap.ml
31+
Impl cmt:tests/lib/bs/src/TypeDefinition.cmt res:tests/src/TypeDefinition.res
32+
Dependency dirs: tests/node_modules/@rescript/react/lib/bs/src tests/node_modules/@rescript/react/lib/bs/src/legacy
3333
Opens from bsconfig:
3434
locItems:
3535
1:18-1:21 Typed map (Belt.List.t<'a>, 'a => 'b) => Belt.List.t<'b> GlobalReference

0 commit comments

Comments
 (0)