PowerShellEditorServices icon indicating copy to clipboard operation
PowerShellEditorServices copied to clipboard

Add document symbols for #region

Open fflaten opened this issue 3 years ago • 1 comments

PR Summary

Adds symbols for region-start, ex. #region abc123, to outline and symbol search.

Note This doesn't check if the region is actually closed as we don't care about the full range since a region can technically start/stop in the middle of a scriptblock.

image

PR Context

Fix PowerShell/vscode-powershell#3604

fflaten avatar Aug 26 '22 16:08 fflaten

Waiting for #1886 as I'd rather get merge conflicts here 🙂

fflaten avatar Aug 26 '22 16:08 fflaten

Heh, ok @fflaten things are so cleaned up now I think you can do this again (much more easily!)

andyleejordan avatar Feb 02 '23 20:02 andyleejordan

Rewrote to use ReferenceTable for caching, but still a WIP. @andschwa: Does it make sense to use ReferenceTable here? It'll make it available for handlers incl. find all references. And it isn't something we'd need to track in the workspace.

Todo:

  • [x] Test with full scriptrange (track endregion)
    • How does outline behave when endregion occurs in the middle of a function/class etc?
  • [x] Validate regex behavior against PowerShell ISE
  • [ ] ~~Move out of ReferenceTable?~~
  • [x] Ignore symbol in scenarios like highlight and hover?

fflaten avatar Feb 14 '23 19:02 fflaten

Does it make sense to use ReferenceTable here?

I'd keep using it, it'll make everything easier. We can add "region" as a symbol type and just exclude them where appropriate.

andyleejordan avatar Feb 14 '23 20:02 andyleejordan

Does it make sense to use ReferenceTable here?

I'd keep using it, it'll make everything easier. We can add "region" as a symbol type and just exclude them where appropriate.

Hm I see what you mean now, since it's not done via AST but simply RegEx, and is only useful for the current document...I'll ponder, I'm sure there's a good way to handle that.

andyleejordan avatar Feb 14 '23 20:02 andyleejordan

  • [x] Test with full scriptrange (track endregion)

    • How does outline behave when endregion occurs in the middle of a function/class etc?

It didn't break as I feared, but only wraps symbols with both start and end position inside. Ex. image

Updated to include it and returning only regions with matching end just like folding. I've disabled hover, highlight (on click) and reference scanning.

Hopefully we'll get some feedback if it becomes too noisy in go to symbol or the outline-nesting. Breadcrumbs require the latter to work, so hopefully worth it.

fflaten avatar Feb 18 '23 12:02 fflaten

Does it make sense to use ReferenceTable here?

I'd keep using it, it'll make everything easier. We can add "region" as a symbol type and just exclude them where appropriate.

I was wrong here 😆

andyleejordan avatar Feb 23 '23 20:02 andyleejordan

Closing since I integrated this, thanks again so much for your work!

andyleejordan avatar Feb 28 '23 22:02 andyleejordan