Skip to content

Commit

Permalink
#115 - Fix for updating added categories/tags
Browse files Browse the repository at this point in the history
  • Loading branch information
estruyf committed Sep 24, 2021
1 parent 71c0360 commit d8bffdc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## [4.0.1] - 2021-09-24

- [#114](https://github.com/estruyf/vscode-front-matter/issues/114): Fix for categories/tags provided as string in YAML
- [#115](https://github.com/estruyf/vscode-front-matter/issues/115): Fix for updating added categories/tags

## [4.0.0] - 2021-09-22 - [Release Notes](https://beta.frontmatter.codes/updates/v4_0_0)

Expand Down
12 changes: 11 additions & 1 deletion src/helpers/SettingsHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { TaxonomyType } from '../models';
import { SETTING_TAXONOMY_TAGS, SETTING_TAXONOMY_CATEGORIES, CONFIG_KEY } from '../constants';
import { Folders } from '../commands/Folders';
import { join, basename } from 'path';
import { existsSync, readFileSync, writeFileSync } from 'fs';
import { existsSync, readFileSync, watch, writeFileSync } from 'fs';
import { Extension } from './Extension';

export class Settings {
Expand Down Expand Up @@ -38,12 +38,22 @@ export class Settings {
* @param callback
*/
public static onConfigChange(callback: (global?: any) => void) {
const projectConfig = Settings.projectConfigPath;

workspace.onDidChangeConfiguration(() => {
callback();
});

// Background listener for when it is not a user interaction
if (projectConfig && existsSync(projectConfig)) {
watch(projectConfig, () => {
callback();
});
}

workspace.onDidSaveTextDocument(async (e) => {
const filename = e.uri.fsPath;

if (Settings.checkProjectConfig(filename)) {
const file = await workspace.openTextDocument(e.uri);
if (file) {
Expand Down

0 comments on commit d8bffdc

Please sign in to comment.