Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missed yamlDefaults and DiagnosticsOptions in version 5 #253

Open
mirismaili opened this issue Oct 7, 2024 · 3 comments
Open

Missed yamlDefaults and DiagnosticsOptions in version 5 #253

mirismaili opened this issue Oct 7, 2024 · 3 comments
Labels
question Further information is requested

Comments

@mirismaili
Copy link

mirismaili commented Oct 7, 2024

I was using yamlDefaults and DiagnosticsOptions in version 4 ...

import {yamlDefaults, type DiagnosticsOptions} from 'monaco-yaml'

... to be able to update schemas dynaically, on demand:

function setNewSchemas(schemas: DiagnosticsOptions['schemas']) {
  const {diagnosticsOptions} = yamlDefaults
  if (!diagnosticsOptions.schemas) return yamlDefaults.setDiagnosticsOptions({...diagnosticsOptions, schemas})

  const newSchemas = [...diagnosticsOptions.schemas]
  for (const schema of schemas ?? []) {
    // Push/Replace `schema` to/in `newSchemas`:
    const existedSimilarSchemaIndex = newSchemas.findIndex(({uri}) => schema.uri === uri)
    if (existedSimilarSchemaIndex === -1) newSchemas.push(schema)
    else newSchemas[existedSimilarSchemaIndex] = schema
  }
  yamlDefaults.setDiagnosticsOptions({...diagnosticsOptions, schemas: newSchemas})
}

Then I upgraded to version 5 and I don't see these two, anymore! How do I preserve the previous functionality?

@remcohaszing
Copy link
Owner

@remcohaszing remcohaszing closed this as not planned Won't fix, can't repro, duplicate, stale Oct 7, 2024
@remcohaszing remcohaszing added the question Further information is requested label Oct 7, 2024
@mirismaili
Copy link
Author

mirismaili commented Oct 8, 2024

OK. But how can I access to the previous configuration (I want to add somethings to it)?

It was accessable using:

const {diagnosticsOptions} = yamlDefaults

... in v4.


But using monacoYaml = configureMonacoYaml(...) in v5, we only have two opions:

  1. update()
  2. dispose()

... according to its type:

export interface MonacoYaml extends IDisposable {
  update: (options: MonacoYamlOptions) => Promise<undefined>
}
export interface IDisposable {
  dispose(): void
}

@remcohaszing

@remcohaszing
Copy link
Owner

remcohaszing commented Oct 11, 2024

That’s fair. I welcome a PR to add a new method getOptions: () => MonacoYamlOptions.

@remcohaszing remcohaszing reopened this Oct 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants