Skip to content
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

Merged
merged 8 commits into from
Mar 3, 2023
Merged

Fantomas: support cursor api #484

merged 8 commits into from
Mar 3, 2023

Conversation

DedSec256
Copy link
Collaborator

@DedSec256 DedSec256 commented Feb 23, 2023

@DedSec256 DedSec256 force-pushed the net231-fantomas-caret branch from b058598 to 2ad070a Compare February 23, 2023 23:26
@DedSec256 DedSec256 marked this pull request as ready for review February 24, 2023 01:17
@DedSec256 DedSec256 force-pushed the net231-fantomas-caret branch from a939f17 to fe0ef02 Compare March 3, 2023 12:09
@DedSec256 DedSec256 requested a review from auduchinok March 3, 2023 12:57
Comment on lines +192 to +193
if (CurrentVersion < Version60)
return new RdFormatResult(formatResult.Replace("\r\n", args.NewLineText), null);
Copy link
Collaborator

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?

Copy link
Contributor

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)

Copy link
Collaborator Author

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.

Copy link
Collaborator

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.

@@ -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)
Copy link
Collaborator

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.

@DedSec256 DedSec256 force-pushed the net231-fantomas-caret branch from 260e80d to 9877c89 Compare March 3, 2023 16:09
@auduchinok auduchinok merged commit 6f52ffa into net231 Mar 3, 2023
@DedSec256 DedSec256 deleted the net231-fantomas-caret branch March 3, 2023 17:14
auduchinok pushed a commit that referenced this pull request Mar 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants