I was playing around with the expand selection to scope and realized that the way I’ve constructed my scopes permits some weird behavior.
So, in the language I’m working on, there are lot of constructs of the type where there is a declaration/prologue section, and then a body section. For instance:
architecture rtl of my_thing is
<declarative items>
begin
<body statements>
end architecture rtl;
This is probably the simplest example, though with subprograms it can get a little messier still as there’s usually also an argument section.
So, in scoping, here’s the stack I’ve created and that you would see as the point moves through the sections.
source.vhdl
source.vhdl meta.block.architecture-declarations.vhdl
source.vhdl meta.block.architecture-body.vhdl
source.vhdl
Now, expand selection to scope seems to work more on scope stack levels than anything. If I place the cursor in the body of the statement, and I expand selection to scope, it’ll grab everything in the body. However if I hit it again, it’ll grab the ENTIRE DOCUMENT. It does not expand to everything in the architecture because the next scope stack level is the base source.vhdl
line.
So, I am wondering, am I violating a good practice in scoping? I could create the following in traversing the same structure:
source.vhdl
source.vhdl meta.block.architecture.vhdl meta.section.architecture-declarations.vhdl
source.vhdl meta.block.architecture.vhdl meta.section.architecture-body.vhdl
source.vhdl.
So, I think in this case, expand selection to scope would behave more predictably. Using the same example as before, I THINK the scope would expand to the body, then the entire architecture, then the entire document.
Here’s the kicker though. The Scope Naming document does state in the meta section that “For example, meta.function.php meta.function.parameters.php
should never occur, but instead the scopes should alternate between meta.function.php
and meta.function.parameters.php
and back to meta.function.php
.” That’s what I’ve done, however again… it messes up expand selection to scope.
Anyone else attempt to go for this level of granularity and did they side with making the editor work properly or adhering to the scope naming document?