Delete theme files more selectively when regenerating them

Avoid deleting files that will be rewritten later, so that Zed
won't observe states where themes are missing if two zed
processes are running at once.
This commit is contained in:
Max Brunsfeld 2022-05-18 14:17:26 -07:00
parent 89e91939e4
commit fbacc12672
2 changed files with 5 additions and 2 deletions

View file

@ -449,7 +449,7 @@ async fn watch_themes(
mut cx: AsyncAppContext, mut cx: AsyncAppContext,
) -> Option<()> { ) -> Option<()> {
let mut events = fs let mut events = fs
.watch("styles/src".as_ref(), Duration::from_millis(250)) .watch("styles/src".as_ref(), Duration::from_millis(100))
.await; .await;
while let Some(_) = events.next().await { while let Some(_) = events.next().await {
let output = Command::new("npm") let output = Command::new("npm")

View file

@ -11,7 +11,10 @@ const tempDirectory = fs.mkdtempSync(path.join(tmpdir(), 'build-themes'));
// Clear existing themes // Clear existing themes
for (const file of fs.readdirSync(themeDirectory)) { for (const file of fs.readdirSync(themeDirectory)) {
if (file.endsWith('.json')) { if (file.endsWith('.json')) {
fs.unlinkSync(path.join(themeDirectory, file)); const name = file.replace(/\.json$/, '');
if (!themes.find(theme => theme.name === name)) {
fs.unlinkSync(path.join(themeDirectory, file));
}
} }
} }