Skip to content
This repository was archived by the owner on Dec 25, 2023. It is now read-only.

Commit e92bdd7

Browse files
authored
Fix pathing in sidebar (#107)
* Remove some unused code * Update nova-extension-utils * Fix tests * Switch to utils clean utility * changelog
1 parent 34a34d9 commit e92bdd7

File tree

9 files changed

+17
-81
lines changed

9 files changed

+17
-81
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"eslint": "^7.11.0",
3838
"eslint-plugin-nova": "^1.1.0",
3939
"jest": "^26.5.3",
40-
"nova-extension-utils": "^1.1.0",
40+
"nova-extension-utils": "^1.2.1",
4141
"onchange": "^7.0.2",
4242
"prettier": "^2.1.2",
4343
"rollup": "^2.32.0",

src/commands/findReferences.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,6 @@ export function registerFindReferences(client: LanguageClient) {
3939
return;
4040
}
4141

42-
if (nova.inDevMode()) {
43-
console.log(JSON.stringify(response, null, " "));
44-
}
45-
4642
createLocationSearchResultsTree(selectedText, response);
4743
}
4844
}

src/commands/findSymbol.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,6 @@ export function registerFindSymbol(client: LanguageClient) {
3434
return;
3535
}
3636

37-
if (nova.inDevMode()) {
38-
console.log(JSON.stringify(response, null, " "));
39-
}
4037
createSymbolSearchResultsTree(response);
4138
}
4239
}

src/requests/publishDiagnostics.test.ts

Lines changed: 0 additions & 28 deletions
This file was deleted.

src/requests/publishDiagnostics.ts

Lines changed: 0 additions & 16 deletions
This file was deleted.

src/searchResults.test.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,29 +239,34 @@ describe("Location search results tree", () => {
239239
expect(provider.getChildren("fileURI2")).toEqual(locations.slice(1));
240240
expect(provider.getTreeItem("fileURI1")).toMatchInlineSnapshot(`
241241
MockTreeItem {
242+
"command": "apexskier.typescript.showSearchResult",
242243
"name": "fileURI1",
243244
"path": "fileURI1",
244245
"state": undefined,
245246
}
246247
`);
247248
expect(provider.getTreeItem(locations[0])).toMatchInlineSnapshot(`
248249
MockTreeItem {
250+
"command": "apexskier.typescript.showSearchResult",
251+
"descriptiveText": ":2:3",
249252
"name": "name",
250253
"state": Symbol(TreeItemCollapsibleState.None),
251254
}
252255
`);
253256
});
254257

255-
it.only("cleans filepaths before rendering them", () => {
258+
it("cleans filepaths before rendering them", () => {
256259
(nova.workspace as any).path = "/workspace";
257260
createLocationSearchResultsTree("name", locations);
258261
const provider: TreeDataProvider<string | lspTypes.SymbolInformation> =
259262
TreeViewTypedMock.mock.calls[0][1].dataProvider;
260263
expect(provider.getTreeItem("file:///workspace/path").name).toBe("./path");
261264
expect(provider.getTreeItem("file:///home/path").name).toBe("~/path");
262265
expect(provider.getTreeItem("file:///path").name).toBe("/path");
266+
267+
(nova.workspace as any).path = null;
263268
expect(
264-
provider.getTreeItem("file:///Volumes/Macintosh HD/home/path").name
269+
provider.getTreeItem("file:///Volumes/Macintosh%20HD/home/path").name
265270
).toBe("~/path");
266271
});
267272
});

src/searchResults.ts

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,9 @@
11
// eslint-disable-next-line no-unused-vars
22
import type * as lspTypes from "vscode-languageserver-protocol";
3+
import { cleanPath } from "nova-extension-utils";
34
import { wrapCommand } from "./novaUtils";
45
import { showLocation } from "./showLocation";
56

6-
// https://stackoverflow.com/a/6969486
7-
function escapeRegExp(string: string) {
8-
return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); // $& means the whole matched string
9-
}
10-
const filePrefix = new RegExp("^" + escapeRegExp("file://"));
11-
12-
const hr = new RegExp("^" + escapeRegExp(`file://${nova.environment["HOME"]}`));
13-
const stdVolumePrefix = new RegExp(
14-
"^" + escapeRegExp("file:///Volumes/Macintosh HD")
15-
);
16-
function cleanPath(path: string) {
17-
const wr = new RegExp("^" + escapeRegExp(`file://${nova.workspace.path}`));
18-
path = decodeURIComponent(path);
19-
path = path.replace(stdVolumePrefix, "file://");
20-
return (
21-
path
22-
.replace(wr, ".")
23-
.replace(hr, "~")
24-
// needs to go last
25-
.replace(filePrefix, "")
26-
);
27-
}
28-
297
type MyTreeProvider<T> = TreeDataProvider<T> & {
308
onSelect(element: T): Promise<void>;
319
};

typescript.novaextension/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## future
44

5+
### Fixed
6+
7+
- Fix paths cleaning in search results sidebar
8+
59
### Breaking
610

711
- Remove functionality now supplied by Nova directly (Go to Definition, Code Action, Offer Suggestions)

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3263,10 +3263,10 @@ normalize-path@^3.0.0, normalize-path@~3.0.0:
32633263
resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-3.0.0.tgz#0dcd69ff23a1c9b11fd0978316644a0388216a65"
32643264
integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==
32653265

3266-
nova-extension-utils@^1.1.0:
3267-
version "1.1.0"
3268-
resolved "https://registry.yarnpkg.com/nova-extension-utils/-/nova-extension-utils-1.1.0.tgz#bcb9d4499af714e963af254b4928c751e8b88344"
3269-
integrity sha512-aFjwAYLWMXxV2MmDdAN4WepnS9jNt7pRXa68UEsj0YvsZmCI6stC6pY7SFNA+i8GLIIp9wdfcmlMTZSNpchz1g==
3266+
nova-extension-utils@^1.2.1:
3267+
version "1.2.1"
3268+
resolved "https://registry.yarnpkg.com/nova-extension-utils/-/nova-extension-utils-1.2.1.tgz#afacdf2e0f01e475a6dbdbb57c14d596c373a9ff"
3269+
integrity sha512-WtIo+TAbGmXnIhB7eNR1H04cCD94sFVWWO9N3EaRKRpkuozs58tkLqChV0wJrmdc/g5Y3vh5593HgS3E8mwSPg==
32703270

32713271
npm-run-path@^2.0.0:
32723272
version "2.0.2"

0 commit comments

Comments
 (0)