<commit_before>#
# Copyright (c) Microsoft. All rights reserved.
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
#

function Out-CurrentFile {
    <#
    .EXTERNALHELP ..\PowerShellEditorServices.Commands-help.xml
    #>
    [CmdletBinding()]
    param(
        [Parameter(ValueFromPipeline, Mandatory=$true)]
        $InputObject
    )

    Begin { $objectsToWrite = @() }
    Process { $objectsToWrite += $InputObject }
    End {
        $outputString = "@`"`r`n{0}`r`n`"@" -f ($objectsToWrite|out-string).Trim()
        $psEditor.GetEditorContext().CurrentFile.InsertText($outputString)
    }
}<commit_msg>Added `AsNewFile` switch to Out-CurrentFile (#869)<commit_after>#
# Copyright (c) Microsoft. All rights reserved.
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
#

function Out-CurrentFile {
    <#
    .EXTERNALHELP ..\PowerShellEditorServices.Commands-help.xml
    #>
    [CmdletBinding()]
    param(
        [Switch]$AsNewFile,

        [Parameter(ValueFromPipeline, Mandatory = $true)]
        $InputObject
    )

    Begin { $objectsToWrite = @() }
    Process { $objectsToWrite += $InputObject }
    End {

        # If requested, create a new file
        if ($AsNewFile) {
            $psEditor.Workspace.NewFile()
        }

        $outputString = "@`"`r`n{0}`r`n`"@" -f ($objectsToWrite|out-string).Trim()

        try {
            # If there is no file open
            $psEditor.GetEditorContext()
        }
        catch {
            # create a new one
            $psEditor.Workspace.NewFile()
        }

        $psEditor.GetEditorContext().CurrentFile.InsertText($outputString)
    }
}
{'fraction_non_alphanumeric': 0.12623618382780685, 'fraction_numerical': 0.0029086678301337987, 'mean_word_length': 2.5833333333333335, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2892895', 'n_tokens_mistral': 519, 'n_tokens_neox': 513, 'n_words': 116}