stevedlawrence commented on issue #165:
URL:
https://github.com/apache/daffodil-vscode/issues/165#issuecomment-1238140294
> initial value of whatever text was on the editor line that triggered the
autosense
This is what I don't really understand. The contents of the current line is
not the context to use to figure out what to use for completion. For example,
in theory you could have an entire schema on a single line with no line breaks.
In which case the wholeLine checks would be meaningless. What really matters is
context immediately around the cursor when the completion is triggered, which
requires look behind the cursor to find the current tag.
Your code works, but I think it's because you're doing the right checks **in
addition** to the wrong wholeLine checks. For example, to complete the
attributes for a sequence, you have this:
```js
if (
checkLastItemOpen(document, position) &&
(wholeLine.includes('<xs:sequence') ||
checkSequenceOpen(document, position))
) {
return getCompletionItems(
[
'dfdl:hiddenGroupRef=',
'dfdl:sequenceKind=',
'dfdl:separator=',
'dfdl:separatorPosition=',
'dfdl:separatorSuppressionPolicy',
],
preVal
)
}
}
```
Whether or not the `wholeLine.includes("<xs:seqeuence")` has nothing to do
with whether you need to provide those completion items. All that matters if
you are inside a sequence tag. I *think* your `checkLastItemOpen` and
`checkSequenceOpen` checks are what do this and why your examples work, though
I haven't dug into exactly what those checks do. Seems these `wholeLine` checks
should be unnecessary.
Note that you don't even really care if a sequence is open. We only care if
we are in a sequence tag. For example, if you have this:
```xml
<xs:sequence |>
...
</xs:sequence>
```
And autocomplete where the pipe is, the sequence isn't really open, but we
are inside a sequence tag. Maybe the checkSequenceOpen takes this into account
and considers it open if it's inside it?
Note that your completion logic for choice only checks `wholeLine` and
doesn't have any checkChoiceOpen or anything. Interestingly, I can't get
choices to autocomplete for me. I'm not sure why it works in your gif, but it
might be related?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]