mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Token calculation fix for Get-Help executed on ScriptBlock for comment help. (#8238)
This commit is contained in:
committed by
Aditya Patwardhan
parent
f27dfea065
commit
a8627b83e5
@@ -1154,10 +1154,10 @@ namespace System.Management.Automation
|
||||
// $sb = { }
|
||||
// set-item function:foo $sb
|
||||
// help foo
|
||||
startTokenIndex = savedStartIndex = FirstTokenInExtent(tokens, ast.Extent) - 1;
|
||||
startTokenIndex = savedStartIndex = FirstTokenInExtent(tokens, ast.Extent) + 1;
|
||||
lastTokenIndex = LastTokenInExtent(tokens, ast.Extent, startTokenIndex);
|
||||
|
||||
Diagnostics.Assert(tokens[startTokenIndex + 1].Kind == TokenKind.LCurly,
|
||||
Diagnostics.Assert(tokens[startTokenIndex - 1].Kind == TokenKind.LCurly,
|
||||
"Unexpected first token in script block");
|
||||
Diagnostics.Assert(tokens[lastTokenIndex].Kind == TokenKind.RCurly,
|
||||
"Unexpected last token in script block");
|
||||
|
||||
@@ -80,6 +80,57 @@ Describe 'get-help HelpFunc1' -Tags "Feature" {
|
||||
# Useless
|
||||
#
|
||||
function helpFunc1 {}
|
||||
|
||||
Set-Item function:dynamicHelpFunc1 -Value {
|
||||
# .SYNOPSIS
|
||||
#
|
||||
# A relatively useless function.
|
||||
#
|
||||
# .DESCRIPTION
|
||||
#
|
||||
# A description
|
||||
#
|
||||
# with indented text and a blank line.
|
||||
#
|
||||
# .NOTES
|
||||
#
|
||||
# This function is mostly harmless.
|
||||
#
|
||||
# .LINK
|
||||
#
|
||||
# http://blogs.msdn.com/powershell
|
||||
#
|
||||
# .LINK
|
||||
#
|
||||
# other commands
|
||||
#
|
||||
# .EXAMPLE
|
||||
#
|
||||
# If you need an example, you're hopeless.
|
||||
#
|
||||
# .INPUTS
|
||||
#
|
||||
# Anything you like.
|
||||
#
|
||||
# .OUTPUTS
|
||||
#
|
||||
# Nothing.
|
||||
#
|
||||
# .COMPONENT
|
||||
#
|
||||
# Something
|
||||
#
|
||||
# .ROLE
|
||||
#
|
||||
# CrazyUser
|
||||
#
|
||||
# .FUNCTIONALITY
|
||||
#
|
||||
# Useless
|
||||
#
|
||||
|
||||
process { }
|
||||
}
|
||||
}
|
||||
|
||||
Context 'Get-Help helpFunc1' {
|
||||
@@ -87,6 +138,11 @@ Describe 'get-help HelpFunc1' -Tags "Feature" {
|
||||
TestHelpFunc1 $x
|
||||
}
|
||||
|
||||
Context 'Get-Help dynamicHelpFunc1' {
|
||||
$x = get-help dynamicHelpFunc1
|
||||
TestHelpFunc1 $x
|
||||
}
|
||||
|
||||
Context 'get-help helpFunc1 -component blah' {
|
||||
$x = get-help helpFunc1 -component blah -ErrorAction SilentlyContinue -ErrorVariable e
|
||||
TestHelpError $x $e 'HelpNotFound,Microsoft.PowerShell.Commands.GetHelpCommand'
|
||||
|
||||
Reference in New Issue
Block a user