From 4a8cc9c8fa0d6d638d82838b68668ef31ca6c1ea Mon Sep 17 00:00:00 2001 From: Albert Ziegenhagel Date: Thu, 22 Jun 2023 08:25:45 +0200 Subject: [PATCH 1/2] bug(linter): prepend default line length args instead of appending them Currently, the default line length arguments for the gfortran linter are appended AFTER the users extraArgs. Since in gfortran, the last occurrence of an argument that is passed multiple times will be taken, the default line length arguments will always overwrite what a user has explicitly set in extraArgs. By prepending the default line length arguments instead, a user should now have the possibility to overwrite the default. --- src/lint/provider.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lint/provider.ts b/src/lint/provider.ts index 5b0cd534..ef4a9083 100644 --- a/src/lint/provider.ts +++ b/src/lint/provider.ts @@ -555,7 +555,9 @@ export class FortranLintingProvider { if (this.linter.name === 'gfortran') { const ln: number = config.get('fortls.maxLineLength'); const lnStr: string = ln === -1 ? 'none' : ln.toString(); - args.push(`-ffree-line-length-${lnStr}`, `-ffixed-line-length-${lnStr}`); + // Prepend via `unshift` to make sure user defined flags overwrite + // the default ones we provide here. + args.unshift(`-ffree-line-length-${lnStr}`, `-ffixed-line-length-${lnStr}`); } if (args.length > 0) this.logger.debug(`[lint] arguments:`, args); From 3485ae0a38cecbe09559150be4e4466cd98ae0ef Mon Sep 17 00:00:00 2001 From: Albert Ziegenhagel Date: Thu, 22 Jun 2023 08:23:57 +0200 Subject: [PATCH 2/2] docs: update CHANGELOG --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 48154f87..f10de928 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -80,6 +80,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Fixed +- Fixed bug where specifying `-ffree-line-length-X` and `-ffixed-line-length-X` + as `linter.extraArgs` would be overridden by the default behaviour of `fortls` + ([#925](https://github.com/fortran-lang/vscode-fortran-support/issues/925)) - Fixed bug where linter would not use the correct Fortran file association if the extension was part of the default extensions of another Fortran lang ID ([#904](https://github.com/fortran-lang/vscode-fortran-support/issues/904))