You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
dart.lineLength setting only works at the workspace level when using LSP #3124
Updated today and noticed this (apparent) regression. I have dart.lineLength set in my project's settings.json file, but Format Document appears to be ignoring this, forcing lines to 80 columns.
Edit: Please let me know what other information I can provide as far as troubleshooting goes. :)
Can you confirm the version of Flutter you're using? My guess is that after upgrading, you accepted the prompt to enable the LSP protocol, so it's a result of that rather than the version. lineLength should be supported in LSP since dart-lang/sdk@ba459f9 though (which I believe should be in the current Flutter stable).
I switched to Flutter stable (1.22.6) and tested this, but it seems to be honouring the dart.lineLength setting for me. I set it to 200 and reformatted a file, and it unwrapped many lines. Setting it to 80 and formatted then caused it to re-wrap them.
LSP is going to become the default in the future, so I'd like to track down why it's not working for some - could you try the following for me to get a log?
Re-enable LSP and reload VS Code
Ensure you can repro in a new project created with Flutter: New Application Project and use that for logging (the log will include parts of the open source files)
Create a new file with just the simple contents below (this will wrap at 80 chars and unwrap at 800 chars)
Run the Dart: Capture Analysis Server Logs command in VS Code
Set dart.lineLength to 80 and format the document
Change the dart.lineLength setting to 800, save the settings, then re-format the document
Click Cancel on the logging notification to stop logging and open the log, then attach it here
var a = [
123456789,
123456789,
123456789,
123456789,
123456789,
123456789,
123456789,
123456789,
123456789,
123456789,
123456789
];
@DanTup You're right, strictly following your steps to reproduce I am unable to reproduce the problem.
My normal workflow includes creating workspaces with multiple folders in them. So after "Create a new file with just the simple contents below" but before "Run the Dart: Capture Analysis Server Logs command in VS Code" I clicked File > Add Folder to Workspace... and selected another folder to add.
At that point I am able to reproduce the problem. Here's the requested log:
Where are you changing the dart.lineLength setting? If you're setting it in a single folder (eg. in the .vscode/settings.json file), that will only apply when you specifically open that folder. If you open a "workspace" (multiple folders at once) then it needs to either be set in your VS Code settings, or the .code-workspace settings.
In my current workflow the setting is set at the folder .vscode/settings.json level, and it seems to be working as desired as long as I keep previewLSP: false.
It's weird that you'd be showing lineLength: 80 in the logs I attached, because as far as I can tell I only have it set in the one place.
It also doesn't make sense to me to require the setting to be set at the workspace level, because a workspace exists at a higher level than the project's Git repository, and developers may be working on a different combination of repositories at any given time. (Hence it would not make sense to commit the workspace anywhere.)
In my current workflow the setting is set at the folder .vscode/settings.json level, and it seems to be working as desired as long as I keep previewLSP: false.
Ah, I think I understand. In the non-LSP version I think we support this as a "resource setting" which means it can be scoped per workspace folder (so if your workspace if you had two projects, they could each have their own setting). There are actually many settings flagged as resource that do not make much sense as such (for example the analyzer log file, which can only exist one per workspace).
The LSP server only supports workspace config, which means it'll only work set at the workspace level or the user settings level.
changed the title [-]Dart-Code 3.19.1 is ignoring dart.lineLength during Format Document[/-][+]dart.lineLength setting only works at the workspace level when using LSP[/+]on Feb 11, 2021
dart-lang/sdk@c881935 has landed in the SDK, and lineLength and enableSdkFormatter are now supported at the WorkspaceFolder level instead of only globally/window level.
Since the change is in the SDK, it will require an SDK update (so may take a little longer to show up than things that only need changes in the VS Code extension).
Activity
DanTup commentedon Feb 5, 2021
Can you confirm the version of Flutter you're using? My guess is that after upgrading, you accepted the prompt to enable the LSP protocol, so it's a result of that rather than the version.
lineLengthshould be supported in LSP since dart-lang/sdk@ba459f9 though (which I believe should be in the current Flutter stable).alexmarkley commentedon Feb 8, 2021
Result of
flutter doctor -v:Also you are correct, I did opt in to the LSP protocol. Setting
"dart.previewLsp": falsesolves the problem for me.DanTup commentedon Feb 9, 2021
I switched to Flutter stable (1.22.6) and tested this, but it seems to be honouring the
dart.lineLengthsetting for me. I set it to 200 and reformatted a file, and it unwrapped many lines. Setting it to 80 and formatted then caused it to re-wrap them.LSP is going to become the default in the future, so I'd like to track down why it's not working for some - could you try the following for me to get a log?
dart.lineLengthto80and format the documentdart.lineLengthsetting to800, save the settings, then re-format the documentThanks!
alexmarkley commentedon Feb 10, 2021
@DanTup You're right, strictly following your steps to reproduce I am unable to reproduce the problem.
My normal workflow includes creating workspaces with multiple folders in them. So after "Create a new file with just the simple contents below" but before "Run the Dart: Capture Analysis Server Logs command in VS Code" I clicked File > Add Folder to Workspace... and selected another folder to add.
At that point I am able to reproduce the problem. Here's the requested log:
Dart-Code-Log-2021-01-02 21-14-09.txt
DanTup commentedon Feb 10, 2021
/in the attached log, the settings include:
Where are you changing the
dart.lineLengthsetting? If you're setting it in a single folder (eg. in the.vscode/settings.jsonfile), that will only apply when you specifically open that folder. If you open a "workspace" (multiple folders at once) then it needs to either be set in your VS Code settings, or the .code-workspace settings.alexmarkley commentedon Feb 10, 2021
In my current workflow the setting is set at the folder
.vscode/settings.jsonlevel, and it seems to be working as desired as long as I keeppreviewLSP: false.It's weird that you'd be showing
lineLength: 80in the logs I attached, because as far as I can tell I only have it set in the one place.It also doesn't make sense to me to require the setting to be set at the workspace level, because a workspace exists at a higher level than the project's Git repository, and developers may be working on a different combination of repositories at any given time. (Hence it would not make sense to commit the workspace anywhere.)
DanTup commentedon Feb 11, 2021
Ah, I think I understand. In the non-LSP version I think we support this as a "resource setting" which means it can be scoped per workspace folder (so if your workspace if you had two projects, they could each have their own setting). There are actually many settings flagged as resource that do not make much sense as such (for example the analyzer log file, which can only exist one per workspace).
The LSP server only supports workspace config, which means it'll only work set at the workspace level or the user settings level.
[-]Dart-Code 3.19.1 is ignoring dart.lineLength during Format Document[/-][+]dart.lineLength setting only works at the workspace level when using LSP[/+][analysis_server] Support resource-specific LSP client configuration
DanTup commentedon Jul 21, 2021
dart-lang/sdk@c881935 has landed in the SDK, and
lineLengthandenableSdkFormatterare now supported at the WorkspaceFolder level instead of only globally/window level.Since the change is in the SDK, it will require an SDK update (so may take a little longer to show up than things that only need changes in the VS Code extension).