-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fantomas: support cursor api #484
Conversation
b058598
to
2ad070a
Compare
ReSharper.FSharp/src/FSharp.Psi.Features/src/CodeCleanup/FSharpReformatCode.fs
Outdated
Show resolved
Hide resolved
...harp/testData/fantomas/FantomasRunOptionsTest/local tool 6_0 with cursor/source/LargeFile.fs
Outdated
Show resolved
Hide resolved
a939f17
to
fe0ef02
Compare
if (CurrentVersion < Version60) | ||
return new RdFormatResult(formatResult.Replace("\r\n", args.NewLineText), null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a comment why this is needed, please?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should be able to pass in lf
as part of the configuration btw.
(And override whatever the user had)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a relic of the past. We can try to rewrite it in a separate PR.
resharper-fsharp/ReSharper.FSharp/src/FSharp.Psi.Features/src/Formatter/FSharpReformatCode.fs
Line 98 in 80620e2
.Replace("\r\n", newLineText) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a comment about the version check would stil be good here. With a link to a PR or a commit.
ReSharper.FSharp/src/FSharp.Psi.Features/src/CodeCleanup/FSharpReformatCode.fs
Outdated
Show resolved
Hide resolved
@@ -79,8 +79,8 @@ type FSharpReformatCode(textControlManager: ITextControlManager) = | |||
sourceFile.GetPsiServices().Files.CommitAllDocuments() | |||
with _ -> () | |||
else | |||
let textControl = textControlManager.VisibleTextControls |> Seq.find (fun c -> c.Document == document) | |||
let cursorPosition = textControl.Caret.Position.Value.ToDocLineColumn() | |||
let textControl = textControlManager.VisibleTextControls |> Seq.tryFind (fun c -> c.Document == document) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if there are multiple editors with the same document? This check seems to ignore which editor was actually focused before the reformat. Please try to use data contexts or other ways to get the proper text control.
260e80d
to
9877c89
Compare
fsprojects/fantomas#2727