Skip to content

Commit 82b0f22

Browse files
committed
refactor(diff): Don't create temporary files
This reverts most of #123 and instead takes a different approach to resolving #94 Use the Git integration for Visual Studio Code (an extension that is bundled with VSCode and neither be disabled or uninstalled, thus can be effectively considered part of VSCode) to read files directly off of Git. Signed-off-by: Lorenz Leutgeb <[email protected]>
1 parent c0216c4 commit 82b0f22

13 files changed

+425
-193
lines changed

.eslintrc.js

+4
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ module.exports = {
2525
'!.*rc.*',
2626
'!*.config.js',
2727
'!*.d.ts',
28+
29+
// Ignore, since this file is vendored from VSCode and should not be changed.
30+
// See `CONTRIBUTING.md`.
31+
'src/types/git.d.ts',
2832
],
2933
rules: {
3034
/*

CHANGELOG.md

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
- use more subtle styling when a reaction involves the local radicle identity (italic text vs border & background)
99
- show "you" instead of local identity's alias
1010
- on hover show the truncated DId next to each identity
11-
- **settings:** add config to toggle excluding temporary files created by the extension, e.g. those used to produce the diff of a patch's changed files, from the list of recently opened files. This is enabled by default. This currently works only partly, but should automatically be fully working when [the underlying VS Code bug](https://github.com/microsoft/vscode/issues/157395#issuecomment-2080293320) is fixed. ([#94](https://github.com/cytechmobile/radicle-vscode-extension/issues/94))
1211
- **patch-list:** show diff for copied and moved files of a patch too when available ([#100](https://github.com/cytechmobile/radicle-vscode-extension/issues/100))
1312
- **patch-list:** show path to containing directory for each changed file of a patch ([#100](https://github.com/cytechmobile/radicle-vscode-extension/issues/100))
1413
- **patch-list:** feat(patch-list): increase count of fetched patches per status to 500 ([#100](https://github.com/cytechmobile/radicle-vscode-extension/issues/100))

CONTRIBUTING.md

+13
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,16 @@ If necessary, specific code shared between extension and webviews should be extr
8989
### Getting user input
9090

9191
Use custom wrapper `askUser()` instead of the native [InputBox API](https://code.visualstudio.com/api/references/vscode-api#InputBox) which would result in procedural, verbose and brittle client code.
92+
93+
## Vendored Dependencies
94+
95+
Types for the [Git integration for VSCode](https://github.com/microsoft/vscode/tree/main/extensions/git) are vendored at [`src/types/git.d.ts`](src/types/git.d.ts).
96+
97+
To update those, proceed as follows:
98+
99+
```sh
100+
$ export VSCODE_TAG="1.88.1" # Adjust this to match desired version of VSCode.
101+
$ git remote add vscode "https://github.com/microsoft/vscode.git"
102+
$ git fetch --depth 1 vscode "$VSCODE_TAG"
103+
$ git show $(git ls-remote --refs --tags vscode "$VSCODE_TAG" | cut -d$'\t' -f1):extensions/git/src/api/git.d.ts > src/types/git.d.ts
104+
```

package.json

+3
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,9 @@
506506
"ts-xor": "^1.3.0",
507507
"typescript": "^5.3.3"
508508
},
509+
"extensionDependencies": [
510+
"vscode.git"
511+
],
509512
"simple-git-hooks": {
510513
"pre-commit": "npm run lint"
511514
},

src/constants.ts

-4
This file was deleted.

src/helpers/command.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { type TextDocumentShowOptions, Uri, commands, window } from 'vscode'
1+
import { type TextDocumentShowOptions, type Uri, commands, window } from 'vscode'
22
import { getExtensionContext, usePatchStore } from '../stores'
33
import { exec, log, showLog } from '../utils'
44
import {
@@ -116,8 +116,8 @@ export function registerAllCommands(): void {
116116
registerVsCodeCmd(
117117
'radicle.openOriginalVersionOfPatchedFile',
118118
async (node: FilechangeNode | undefined) => {
119-
if (node?.oldVersionUrl) {
120-
await commands.executeCommand('vscode.open', Uri.file(node.oldVersionUrl))
119+
if (node?.oldVersionUri) {
120+
await commands.executeCommand('vscode.open', node.oldVersionUri)
121121
commands.executeCommand('workbench.action.files.setActiveEditorReadonlyInSession')
122122
} else {
123123
log(
@@ -131,8 +131,8 @@ export function registerAllCommands(): void {
131131
registerVsCodeCmd(
132132
'radicle.openChangedVersionOfPatchedFile',
133133
async (node: FilechangeNode | undefined) => {
134-
if (node?.newVersionUrl) {
135-
await commands.executeCommand('vscode.open', Uri.file(node.newVersionUrl))
134+
if (node?.newVersionUri) {
135+
await commands.executeCommand('vscode.open', node.newVersionUri)
136136
commands.executeCommand('workbench.action.files.setActiveEditorReadonlyInSession')
137137
} else {
138138
log(

src/helpers/config.ts

-6
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ export interface ExtensionConfig {
1313
'radicle.advanced.pathToRadBinary': string
1414
'radicle.advanced.pathToNodeHome': string
1515
'radicle.advanced.httpApiEndpoint': string
16-
'radicle.hideTempFiles': boolean
1716
}
1817

1918
/**
@@ -33,10 +32,7 @@ export function getConfig<K extends keyof ExtensionConfig>(
3332
case 'radicle.advanced.httpApiEndpoint':
3433
// if the config has the value of the empty string (default) then return `undefined`
3534
// @ts-expect-error
36-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call
3735
return config.get<ExtensionConfig[K]>(configKey)?.trim() || undefined
38-
case 'radicle.hideTempFiles':
39-
return config.get<ExtensionConfig[K]>(configKey)
4036
default:
4137
return assertUnreachable(configKey)
4238
}
@@ -56,8 +52,6 @@ export function setConfig<K extends keyof ExtensionConfig>(
5652
case 'radicle.advanced.pathToNodeHome':
5753
case 'radicle.advanced.httpApiEndpoint':
5854
return config.update(configKey, value, ConfigurationTarget.Global)
59-
case 'radicle.hideTempFiles':
60-
return config.update(configKey, value, ConfigurationTarget.Global)
6155
default:
6256
return assertUnreachable(configKey)
6357
}

src/helpers/configWatcher.ts

-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { workspace } from 'vscode'
22
import {
3-
validateHideTempFilesConfigAlignment,
43
validateHttpdConnection,
54
validateRadCliInstallation,
65
validateRadicleIdentityAuthentication,
@@ -52,11 +51,6 @@ const configWatchers = [
5251
usePatchStore().resetAllPatches()
5352
},
5453
},
55-
{
56-
configKey: 'radicle.hideTempFiles',
57-
onConfigChange: validateHideTempFilesConfigAlignment,
58-
onBeforeWatcherRegistration: validateHideTempFilesConfigAlignment,
59-
},
6054
] satisfies OnConfigChangeParam[]
6155

6256
/**
@@ -65,7 +59,6 @@ const configWatchers = [
6559
*/
6660
export function registerAllConfigWatchers(): void {
6761
configWatchers.forEach((cw) => {
68-
cw.onBeforeWatcherRegistration?.()
6962
onConfigChange(cw.configKey, cw.onConfigChange)
7063
})
7164
}

0 commit comments

Comments
 (0)