Inconsistency in generated `open` location between Code Completion and Code Fix
Inconsistency in generated open location between Code Completion and Code Fix
When completing (Ctrl+Space) a type in an unopened Namespace, its open gets automatically generated. Alternatively the open can be generated via Code Fix (Ctrl+.) on a type in unopened namespace.
But currently these open get generated at different locations:
- Code Completion: Nearest possible place (-> nearest module)
- Code fix: Top level (-> root module)
Example:
module Root
module Nested =
let foo () =
Regex
// ^ cursor is here
open locations:
- Code Completion:
module Root module Nested = open System.Text.RegularExpressions let foo () = Regex - Code fix:
module Root open System.Text.RegularExpressions module Nested = let foo () = Regex
These two should have same behaviour.
- Default: probably Nearest (like it's currently with code completion)
- Probably introduce a setting for default location
- Choice for Code Fix (-> two
open XXXXfixes with differentopenlocations)- Default location (based on setting) should have higher priority in list (come before other location)
Additional by baronfel (https://github.com/fsharp/FsAutoComplete/pull/788#issuecomment-857000143):
Regarding your note, I've noticed that myself and haven't yet come to a decision on how to handle it. I think it's safest to go to Nearest by default, but I do agree that we could easily make it an option for the user for the codefix. For code completion I think a user setting would be the correct way to go, which we would just need to add to the config DTO and flow down into other layers as appropriate.
Closing as #788 (released in 0.46.2) fixed this.
#788 "just" fixes some cases where opens from Code Completions are inserted into invalid places (and such producing compiler errors).
But the basic behaviour of both wasn't changed: Code Completion still opens in nearest location, Code Fix in top level
-> this issue isn't solved
Oh of course, this was the issue you added specifically to address that inconsistency.