`getDocumentSymbols` returns incorrect ordered symbol list in flatten mode
See original GitHub issuemonaco-editor version: 0.24.0 **Browser: Chrome 91.0.4472.77 **OS: macOS 12.0 Beta Playground code that reproduces the issue:
https://alauda.github.io/k8s-form-in-action/demo/
Change the yaml content like the following:
containers:
- name: nginx
ports:
- containerPort: 80
open devtool, execute window.DEBUG = true
, click the yaml content you will get
As you can see, name
symbol comes before 0
which is incorrect obviously, while containerPort
comes after 0
which is correct.
What means when a symbol has multi children, the flatted result is incorrect.
If you want to run this sample locally, you can check https://github.com/alauda/k8s-form-in-action
run yarn && yarn dev
and then visit http://localhost:4200
The related source code is at https://github.com/alauda/k8s-form-in-action/blob/master/src/app/demo/component.ts#L168
Issue Analytics
- State:
- Created 2 years ago
- Comments:14 (8 by maintainers)
I did some digging into this…
@
to jump to the symbol. In my screenshot I’ve added some whitespace after creating the editor so you can see both the code and the list of symbols for illustrative purposes.compareRangesUsingStarts(*)
. You can see this change by running the above JavaScript code in the Monaco Editor Playground. The calling code can be found here and you can keep walking backwards from there as desired.getDocumentSymbols(*)
function is not considered API based on the contents of thevscode.d.ts
file or themonaco.d.ts
file so you shouldn’t be using it to get an outline of the symbols from a model.Can’t offer much help here, but as far as I know the Monaco editor does not provide any language intelligence for YAML out-of-the-box. So where are these symbols computed? Where does the
DocumentSymbolProvider
come from? I would start there and look into the ordering coming directly from that provider. That would probably also help you in providing a minimal repro if there should be a bug on Monaco’s side.