-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
182 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
...as/FantomasRunOptionsTest/local tool 6_0 with cursor/gold/local tool 6_0 with cursor.gold
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
namespace JetBrains.ReSharper.Plugins.FSharp.Services.Formatter | ||
|
||
[<CodeCleanupModule>] | ||
type FSharpReformatCode(textControlManager: ITextControlManager) = | ||
member x.Process(sourceFile, rangeMarker, _, _, _) = | ||
if isNotNull rangeMarker then | ||
try<caret> | ||
let range = ofDocumentRange rangeMarker.DocumentRange | ||
|
||
let formatted = | ||
fantomasHost.FormatSelection(filePath, range, text, settings, parsingOptions, newLineText) | ||
|
||
let offset = rangeMarker.DocumentRange.StartOffset.Offset | ||
let oldLength = rangeMarker.DocumentRange.Length | ||
|
||
let documentChange = | ||
DocumentChange(document, offset, oldLength, formatted, stamp, modificationSide) | ||
|
||
use _ = WriteLockCookie.Create() | ||
document.ChangeDocument(documentChange, TimeStamp.NextValue) | ||
sourceFile.GetPsiServices().Files.CommitAllDocuments() | ||
with _ -> | ||
() | ||
else | ||
let textControl = | ||
textControlManager.VisibleTextControls | ||
|> Seq.find (fun c -> c.Document == document) | ||
|
||
cursorPosition = textControl.Caret.Position.Value.ToDocLineColumn() |
19 changes: 19 additions & 0 deletions
19
...p/testData/fantomas/FantomasRunOptionsTest/local tool 6_0 with cursor/source/LargeFile.fs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
namespace JetBrains.ReSharper.Plugins.FSharp.Services.Formatter | ||
|
||
[<CodeCleanupModule>] | ||
type FSharpReformatCode(textControlManager: ITextControlManager) = | ||
member x.Process(sourceFile, rangeMarker, _, _, _) = | ||
if isNotNull rangeMarker then | ||
try<caret> | ||
let range = ofDocumentRange rangeMarker.DocumentRange | ||
let formatted = fantomasHost.FormatSelection(filePath, range, text, settings, parsingOptions, newLineText) | ||
let offset = rangeMarker.DocumentRange.StartOffset.Offset | ||
let oldLength = rangeMarker.DocumentRange.Length | ||
let documentChange = DocumentChange(document, offset, oldLength, formatted, stamp, modificationSide) | ||
use _ = WriteLockCookie.Create() | ||
document.ChangeDocument(documentChange, TimeStamp.NextValue) | ||
sourceFile.GetPsiServices().Files.CommitAllDocuments() | ||
with _ -> () | ||
else | ||
let textControl = textControlManager.VisibleTextControls |> Seq.find (fun c -> c.Document == document) | ||
cursorPosition = textControl.Caret.Position.Value.ToDocLineColumn(); |