-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow wrapping container with container #44868
Comments
@Kavantix This sounds like a flutter specific issue. Could you maybe file this bug in the flutter repository instead: flutter/flutter ? Or is this related to some editor / analyzer refactoring tools? |
Well yes it is flutter specific, but as far as I could tell this repo is the one implementing the refactoring (also for flutter). |
/cc @devoncarew Maybe you could correctly triage this issue? |
Yup, this is the right repo :) We don't show |
Well the most important one for me personally is that I use it to wrap a widget with any other widget since wrap with widget gives me an error until I put the actual widget there. As for a valid usecase of two containers, I agree that 99% of the time you should simply collapse them into one but I could imagine someone to for instance do some color, padding and alignment on the outer container and a different color and some constraints on the inner container. So TLDR the usecases are extremely limited, I would just like to have it so I can wrap a container with a widget without the analysis server showing me an error because |
Ah, ok.
I think this is a limitation of the current emacs / analysis server integration. For the refactoring, we pass the text to insert as well as a selection range after the insertion is complete. For other IDEs (VS Code, IntelliJ), the Can you re-file this issue as an enhancement against whichever emacs / dart integration you're using? |
I’m not using emacs, I use coc.nvim in nvim and it does also select the text which I can type over just like vscode and such. If adding wrap with container on a container won’t happen (which I feel like you’re inferring?) then indeed somehow we need to be able to ignore the error until the user entered the name of the widget. Btw, I just wanna say as well that it’s really nice that the lsp version is getting some more love lately, enabling things like the |
As you can see in the image in vscode on the previewLsp setting it also shows an error because Btw I also noticed that this one in fact is not given as a snippet so it does not allow you to put the name of the widget in (both in vscode and the vim extension). I probably confused it with another autocomplete. |
Oops, sorry, I read vim but typed emacs.
Hmm, I do see the What version of flutter are you using? I'm running against the latest from master. I think the error after completion is expected - |
I'm also using the latest master and both the big multi-line error and the widget being selected don't work It does work if vscode is not in @DanTup FYI, maybe you also have some info on this? |
There's a limitation in the LSP spec that prevents us from pre-selected text from code-actions. This means the There are some open issues requesting support in LSP here that you can 👍
There are comments saying that VS Code doesn't support this, which is why LSP doesn't (things are only added to LSP when there is a client that can use them). In VS Code when LSP is disabled, we used a different way of applying edits that uses a command that could call It could be handled via a custom command, but it would need specific support in each client so that's really a last-resort option. Having something added to the LSP spec would be much better because it wouldn't require editors to implement Dart-lsp-specific commands. I added a note on microsoft/language-server-protocol#724 (comment) to see whether it's likely there will be movement on it, and also suggesting a possible simple way of providing a selection-range without needing full snippet support. As for the long range, it sounds like #44598 but that should be fixed on Flutter master. Can you confirm the exact error message and error code being reported when you see this? |
Yes you're right the long range is indeed improved on master, not sure why I didn't see it before. I'll thumbs up the other issues. But as for this exact issue, it having giving the error would simply be solved if we could wrap every widget with a container since that's never an error. |
@Kavantix I'm not sure I entirely understand the request. If you're planning on wrapping with a different widget, what's the value in using I think it would be preferable to improve |
Well yeah, the short period in which it shows an error is not needed and bothers me personally, and in vim the analysis only updates when I leave inset mode so if I’m swapping out Container for another widget name I never see any error. I do agree though that improving wrap with widget is another good and perhaps better option. |
FWIW, the Dart LSP server (and VS Code extension) implement an experimental custom extension to LSP proposed by the Rust team to now select the It's not officially part of LSP, but it's possible it would be merged in the future and it's used by at least Dart and Rust, so it might be something to propose for the LSP client you're using. |
Currently the
Wrap with Container
refactoring works on all widgets except theContainer
widget itself.Could we allow this to be done?
There are valid cases for doing this
I'm currently using
Wrap with Container
in vim in favor ofWrap with widget...
since that insertswidget(
which is seen as an error sincewidget
is not a valid function or classThe text was updated successfully, but these errors were encountered: