Skip to content

Commit

Permalink
chore: remove facilities for temporary files
Browse files Browse the repository at this point in the history
Signed-off-by: Lorenz Leutgeb <[email protected]>
  • Loading branch information
lorenzleutgeb committed Apr 30, 2024
1 parent a669d86 commit ba8232f
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 78 deletions.
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
- use more subtle styling when a reaction involves the local radicle identity (italic text vs border & background)
- show "you" instead of local identity's alias
- on hover show the truncated DId next to each identity
- **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))
- **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))
- **patch-list:** show path to containing directory for each changed file of a patch ([#100](https://github.com/cytechmobile/radicle-vscode-extension/issues/100))
- **patch-list:** feat(patch-list): increase count of fetched patches per status to 500 ([#100](https://github.com/cytechmobile/radicle-vscode-extension/issues/100))
Expand Down
10 changes: 0 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -443,16 +443,6 @@
}
],
"configuration": [
{
"properties": {
"radicle.hideTempFiles": {
"scope": "application",
"type": "boolean",
"default": "true",
"description": "Exclude temporary files generated by the extension (e.g. old/new versions of files changed in patches) from being listed among the recently opened or in search."
}
}
},
{
"title": "Advanced",
"properties": {
Expand Down
4 changes: 0 additions & 4 deletions src/constants.ts

This file was deleted.

6 changes: 0 additions & 6 deletions src/helpers/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export interface ExtensionConfig {
'radicle.advanced.pathToRadBinary': string
'radicle.advanced.pathToNodeHome': string
'radicle.advanced.httpApiEndpoint': string
'radicle.hideTempFiles': boolean
}

/**
Expand All @@ -33,10 +32,7 @@ export function getConfig<K extends keyof ExtensionConfig>(
case 'radicle.advanced.httpApiEndpoint':
// if the config has the value of the empty string (default) then return `undefined`
// @ts-expect-error
// eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call
return config.get<ExtensionConfig[K]>(configKey)?.trim() || undefined
case 'radicle.hideTempFiles':
return config.get<ExtensionConfig[K]>(configKey)
default:
return assertUnreachable(configKey)
}
Expand All @@ -56,8 +52,6 @@ export function setConfig<K extends keyof ExtensionConfig>(
case 'radicle.advanced.pathToNodeHome':
case 'radicle.advanced.httpApiEndpoint':
return config.update(configKey, value, ConfigurationTarget.Global)
case 'radicle.hideTempFiles':
return config.update(configKey, value, ConfigurationTarget.Global)
default:
return assertUnreachable(configKey)
}
Expand Down
7 changes: 0 additions & 7 deletions src/helpers/configWatcher.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { workspace } from 'vscode'
import {
validateHideTempFilesConfigAlignment,
validateHttpdConnection,
validateRadCliInstallation,
validateRadicleIdentityAuthentication,
Expand Down Expand Up @@ -52,11 +51,6 @@ const configWatchers = [
usePatchStore().resetAllPatches()
},
},
{
configKey: 'radicle.hideTempFiles',
onConfigChange: validateHideTempFilesConfigAlignment,
onBeforeWatcherRegistration: validateHideTempFilesConfigAlignment,
},
] satisfies OnConfigChangeParam[]

/**
Expand All @@ -65,7 +59,6 @@ const configWatchers = [
*/
export function registerAllConfigWatchers(): void {
configWatchers.forEach((cw) => {
cw.onBeforeWatcherRegistration?.()
onConfigChange(cw.configKey, cw.onConfigChange)
})
}
52 changes: 2 additions & 50 deletions src/ux/settings.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import { sep } from 'node:path'
import { ConfigurationTarget, commands, workspace } from 'vscode'
import { extTempDir } from '../constants'
import { getConfig } from '../helpers'
import { log } from '../utils'
import { commands, workspace } from 'vscode'
import type { getConfig } from '../helpers'

/**
* Opens the Settings UI with the options filtered to show only the specified config
Expand All @@ -19,48 +16,3 @@ export function openSettingsFocusedAtConfig(config: Parameters<typeof getConfig>
config,
)
}

/**
* Checks extension config for user's desired behaviour and ensure's the
* native vscode config is set to match.
*/
export function validateHideTempFilesConfigAlignment() {
const excludeGlob = `${extTempDir}${sep}**`

const shouldExclude = getConfig('radicle.hideTempFiles')

const searchExcludeConfigKey = 'search.exclude'
const searchExcludeConfig = workspace.getConfiguration().get<object>(searchExcludeConfigKey)

if (!searchExcludeConfig) {
log(
`Didn't find any configuration for key "${searchExcludeConfigKey}". Bailing validation of config alignment.`,
'warn',
)

return
}

const isAlreadyConfigedToExclude = Boolean(
Object.entries(searchExcludeConfig).find(
([key, value]) => key === excludeGlob && value === true,
),
)

if (shouldExclude && !isAlreadyConfigedToExclude) {
const newSearchExcludeConfig = { ...searchExcludeConfig, [excludeGlob]: true }
workspace
.getConfiguration()
.update(searchExcludeConfigKey, newSearchExcludeConfig, ConfigurationTarget.Global)
} else if (!shouldExclude && isAlreadyConfigedToExclude) {
// @ts-expect-error Type '{}' has no matching index signature for type 'string'.
const { [excludeGlob]: _, ...searchExcludeConfigWithoutExcludeGlob } = searchExcludeConfig
workspace
.getConfiguration()
.update(
searchExcludeConfigKey,
searchExcludeConfigWithoutExcludeGlob,
ConfigurationTarget.Global,
)
}
}

0 comments on commit ba8232f

Please sign in to comment.