Skip to content

Commit d61757c

Browse files
committed
fix(formatter): update vscode settings on change
Fixes #1007
1 parent e48ccb4 commit d61757c

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
8080

8181
### Fixed
8282

83+
- Fixed bug where formatting arguments would not be updated from settings.json
84+
([[#1007](https://github.com/fortran-lang/vscode-fortran-support/issues/1007)])
8385
- Fixed bug where specifying `-ffree-line-length-X` and `-ffixed-line-length-X`
8486
as `linter.extraArgs` would be overridden by the default behaviour of `fortls`
8587
([#925](https://github.com/fortran-lang/vscode-fortran-support/issues/925))

src/format/provider.ts

+9-2
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,16 @@ import {
1616
} from '../util/tools';
1717

1818
export class FortranFormattingProvider implements vscode.DocumentFormattingEditProvider {
19-
private readonly workspace = vscode.workspace.getConfiguration(EXTENSION_ID);
19+
private workspace = vscode.workspace.getConfiguration(EXTENSION_ID);
2020
private formatter: string | undefined;
21-
constructor(private logger: Logger) {}
21+
constructor(private logger: Logger) {
22+
vscode.workspace.onDidChangeConfiguration(e => {
23+
if (e.affectsConfiguration(`${EXTENSION_ID}.formatting`)) {
24+
this.logger.debug('[format] Configuration changed, reloading formatter');
25+
this.workspace = vscode.workspace.getConfiguration(EXTENSION_ID);
26+
}
27+
});
28+
}
2229

2330
public async provideDocumentFormattingEdits(
2431
document: vscode.TextDocument,

0 commit comments

Comments
 (0)