ionide / ionide/FsAutoComplete
Inconsistency in generated `open` location between Code Completion and Code Fix
- Dominant language
- F#
- Stars
- 486
- Forks
- 169
- Avg merge
- 2d 8h
- Merged PRs (30d)
- 5
Description
# 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:
```fsharp
module Root
module Nested =
let foo () =
Regex
// ^ cursor is here
```
open locations:
* Code Completion:
```fsharp
module Root
module Nested =
open System.Text.RegularExpressions
let foo () =
Regex
```
* Code fix:
```fsharp
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 XXXX` fixes with different `open` locations)
* 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.
Contributor guide
Research direction
Start by tracing the code-completion and code-fix paths that generate open declarations, then compare how each chooses its insertion location. Review the linked discussion before deciding between nearest-by-default, a setting, or multiple code-fix choices. Done means both paths have an agreed, tested location policy.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- fsharp
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100