diff --git a/src/FsAutoComplete/CodeFixes/RenameUnusedValue.fs b/src/FsAutoComplete/CodeFixes/RenameUnusedValue.fs index d6eb69f42..e8b5e74af 100644 --- a/src/FsAutoComplete/CodeFixes/RenameUnusedValue.fs +++ b/src/FsAutoComplete/CodeFixes/RenameUnusedValue.fs @@ -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 [] diff --git a/test/FsAutoComplete.Tests.Lsp/CodeFixTests/Tests.fs b/test/FsAutoComplete.Tests.Lsp/CodeFixTests/Tests.fs index 5df7d29a6..b540170bb 100644 --- a/test/FsAutoComplete.Tests.Lsp/CodeFixTests/Tests.fs +++ b/test/FsAutoComplete.Tests.Lsp/CodeFixTests/Tests.fs @@ -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 =