Closed
Description
System Details
- Operating system name and version: Win10 x64
- VS Code version: 1.8.1
- PowerShell extension version: 0.9.0
- Output from
$PSVersionTable
:
Name Value
---- -----
PSVersion 5.1.14393.693
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.14393.693
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Issue Description
Hi, I am not sure if this has been reported before, but multi-line strings do not seem to store correctly within powershell scripts when they are not left aligned to line space 0. If the closing '"@' is not in space 0, all code following this end marker is highlighted as a continuation of the comment block.
E.g. the following code displays only the required multi-line string as a intended.
$DefaultConfigFile = @"
@{
# Specify the desired logs directory, by default this is the current working directory in a subfolder named logs
LogFileDirectory = '.\Logs'
# Specify the desired log file prefix, the default prefix is the first token of the last line of input
LogFilePrefix = 'ChangeMe'
# Specify the log file extension, this can be safely left at .txt, please include the leading full stop
LogFileExtension = '.txt'
# Specify the log datestamp format, this string will be passed to Get-Date -Format
LogFileDateFormat = 'yyyyMMddHHmm'
# Specify the amount of days that the logs will be retained for
LogFileRetentionPeriod = 10
}
"@
Add-Content -Path ($pwd.Path + '\' + 'Out-Log.conf.psd1') -Value $DefaultConfigFile
Whereas the following code shows the rest of the script as a singular string, causing code warnings (Red squiggly lines)
$DefaultConfigFile = @"
@{
# Specify the desired logs directory, by default this is the current working directory in a subfolder named logs
LogFileDirectory = '.\Logs'
# Specify the desired log file prefix, the default prefix is the first token of the last line of input
LogFilePrefix = 'ChangeMe'
# Specify the log file extension, this can be safely left at .txt, please include the leading full stop
LogFileExtension = '.txt'
# Specify the log datestamp format, this string will be passed to Get-Date -Format
LogFileDateFormat = 'yyyyMMddHHmm'
# Specify the amount of days that the logs will be retained for
LogFileRetentionPeriod = 10
}
"@
Add-Content -Path ($pwd.Path + '\' + 'Out-Log.conf.psd1') -Value $DefaultConfigFile
Sorry about the rough formatting, I am currently out on the road so I am not able to make it look "pretty" or upload logs.
Cheers,
SubThr33