Skip to content

Commit

Permalink
don't trigger "Replace/Prefix with _" on Wild (#1083)
Browse files Browse the repository at this point in the history
  • Loading branch information
dawedawe authored Mar 19, 2023
1 parent 613efd8 commit 35a8ca9
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/FsAutoComplete/CodeFixes/RenameUnusedValue.fs
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,18 @@ let fix (getParseResultsForFile: GetParseResultsForFile) =
if mfv.IsMemberThisValue then
return [ mkReplaceFix diagnostic.Range ]
elif mfv.IsValue then
return
[ tryMkValueReplaceFix diagnostic.Range; tryMkPrefixFix diagnostic.Range ]
|> List.choose id
let symbolText =
lines.GetText symbolUse.Range
|> function
| Ok r -> r
| Error _ -> ""

if symbolText <> "_" then
return
[ tryMkValueReplaceFix diagnostic.Range; tryMkPrefixFix diagnostic.Range ]
|> List.choose id
else
return []
else
return []
| _ -> return []
Expand Down
16 changes: 16 additions & 0 deletions test/FsAutoComplete.Tests.Lsp/CodeFixTests/Tests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1698,6 +1698,22 @@ let private renameUnusedValue state =
"""
(Diagnostics.acceptAll)
selectPrefix

testCaseAsync "prefix doesn't trigger for _" <|
CodeFix.checkNotApplicable server
"""
let $0_ = 6
"""
(Diagnostics.acceptAll)
selectPrefix

testCaseAsync "replace doesn't trigger for _" <|
CodeFix.checkNotApplicable server
"""
let $0_ = 6
"""
(Diagnostics.acceptAll)
selectReplace
])

let private replaceWithSuggestionTests state =
Expand Down

0 comments on commit 35a8ca9

Please sign in to comment.