Skip to content

Commit 2050264

Browse files
committed
Fixes Allow linter activation without extension restart #296
1 parent 7afcf8b commit 2050264

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1313

1414
- Fixes linting regex to capture a wider spectrum of errors
1515
([#295](https://github.com/krvajal/vscode-fortran-support/issues/295))
16+
- Fixes linter activation from `Disabled` to some compiler `X` without having
17+
to restart the extension
18+
([#296](https://github.com/krvajal/vscode-fortran-support/issues/296))
1619

1720
### Changed
1821

src/extension.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,10 @@ export async function activate(context: vscode.ExtensionContext) {
3434
loggingService.logInfo(`Hover set to: ${hoverType}`);
3535
loggingService.logInfo(`Symbols set to: ${symbolsType}`);
3636

37-
if (linterType !== 'Disabled') {
38-
const linter = new FortranLintingProvider(loggingService);
39-
linter.activate(context.subscriptions);
40-
vscode.languages.registerCodeActionsProvider(FortranDocumentSelector(), linter);
41-
}
37+
// Linter is always activated but will only lint if compiler !== Disabled
38+
const linter = new FortranLintingProvider(loggingService);
39+
linter.activate(context.subscriptions);
40+
vscode.languages.registerCodeActionsProvider(FortranDocumentSelector(), linter);
4241

4342
if (formatterType !== 'Disabled') {
4443
const disposable: vscode.Disposable = vscode.languages.registerDocumentFormattingEditProvider(

src/features/linter-provider.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ export class FortranLintingProvider {
5252
}
5353

5454
private doModernFortranLint(textDocument: vscode.TextDocument) {
55+
// Only lint if a compiler is specified
56+
const config = vscode.workspace.getConfiguration('fortran.linter');
57+
if (config.get<string>('fortran.linter.compiler') === 'Disabled') return;
5558
// Only lint Fortran (free, fixed) format files
5659
if (
5760
!FortranDocumentSelector().some(e => e.scheme === textDocument.uri.scheme) ||

0 commit comments

Comments
 (0)