In VS: renaming an operator containing . only renames right of ., but keeps everything left (including .) of .
Repro steps
let (-.-) a b = a + b
let _ = 1 -.- 2
Rename (F2) on -.- (doesn't matter if decl or usage)
-> only last - gets selected and replaced when renamed with something:

Expected behavior
Select and rename complete operator
Actual behavior
Selects and renames only right of .
Known workarounds
Rename all with Search&Rename
Related information
I think the issue is in:
|
/// Fix invalid span if it appears to have redundant suffix and prefix. |
|
let fixupSpan (sourceText: SourceText, span: TextSpan) : TextSpan = |
|
let text = sourceText.GetSubText(span).ToString() |
|
// backticked ident |
|
if text.EndsWith "``" then |
|
match text.LastIndexOf("``", text.Length - 3, text.Length - 2) with |
|
| -1 | 0 -> span |
|
| index -> TextSpan(span.Start + index, text.Length - index) |
|
else |
|
match text.LastIndexOf '.' with |
|
| -1 | 0 -> span |
|
| index -> TextSpan(span.Start + index + 1, text.Length - index - 1) |
span gets adjusted to remove parts like leading Namespaces, Modules, Types. This is done by retrieving text after last
. (if no backticks). For normal identifiers that's ok -- but
. is allowed in operators ->
TextSpan for operators with
. only contains part right of
. (
-.- ->
-)
Provide any related information (optional):
- Win 11 x64
- Microsoft Visual Studio Community 2022 (64-bit) Version 17.3.5
In VS: renaming an operator containing
.only renames right of., but keeps everything left (including.) of.Repro steps
Rename (
F2) on-.-(doesn't matter if decl or usage)-> only last
-gets selected and replaced when renamed with something:Expected behavior
Select and rename complete operator
Actual behavior
Selects and renames only right of
.Known workarounds
Rename all with Search&Rename
Related information
I think the issue is in:
fsharp/vsintegration/src/FSharp.Editor/LanguageService/Tokenizer.fs
Lines 802 to 813 in fcd06c7
spangets adjusted to remove parts like leading Namespaces, Modules, Types. This is done by retrieving text after last.(if no backticks). For normal identifiers that's ok -- but.is allowed in operators ->TextSpanfor operators with.only contains part right of.(-.-->-)Provide any related information (optional):