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

getRawOptions is not compatible with older getConfiguration #1734

Closed
brijeshb42 opened this issue Dec 26, 2019 · 7 comments
Closed

getRawOptions is not compatible with older getConfiguration #1734

brijeshb42 opened this issue Dec 26, 2019 · 7 comments
Assignees
Labels
editor-api feature-request Request for new features or functionality
Milestone

Comments

@brijeshb42
Copy link
Contributor

brijeshb42 commented Dec 26, 2019

monaco-editor version: 0.19.0
Browser: Any
OS: any
Playground code that reproduces the issue:

const editor = monaco.editor.create(document.getElementById("container"), {
	value: "",
	language: "json",
});
const options = editor.getRawOptions();
editor.setValue(JSON.stringify(options, null, 2));

Expected: The result should have all the supported options in the editor.
Actual: It returns only those values that have been explicitly set/updated.

If this is already the expected behavior, how can I actually access other option's values. In my particular use case, I need to check if the editor is read-only or not.

@brijeshb42
Copy link
Contributor Author

There is editor.getOption(optionID). But in this case, there is no reliable way to access IDs for each of the options. readOnly's id is 65.

@alexdima alexdima added editor-api feature-request Request for new features or functionality labels Jan 6, 2020
@alexdima
Copy link
Member

alexdima commented Jan 6, 2020

The internal/computed editor options are not in the API anymore.

That is because they have been internally migrated to an array/enum based system, and the enum values are expected to change all the time... So hard coding 65 is dangerous and will very likely break with future releases. Moreover, I thought that since the editor respects the passed in options, and never changes the options by itself, it is easy for someone to keep track on the outside, e.g.

let isReadOnly = false; // tracks the readOnly state of the editor
function makeReadOnly(editor) {
  isReadOnly = true;
  editor.updateOptions({ readOnly: isReadOnly });
}
function makeEditable(editor) {
  isReadOnly = false;
  editor.updateOptions({ readOnly: isReadOnly });
}

@alexdima alexdima added this to the Backlog milestone Jan 6, 2020
@alexdima alexdima removed their assignment Jan 6, 2020
@brijeshb42
Copy link
Contributor Author

brijeshb42 commented Jan 6, 2020

What if the enums were exposed in the monaco.editor.* api to be used? For me, readOnly was just an example. There are lot of other options that I would like to access, like fontSize, cursorWidth and it wouldn't be reliable to expect that users of monaco-editor would create their editors with all the options that my library (monaco-vim) requires.

@blois
Copy link

blois commented Jan 10, 2020

+1 to these concerns.

We are using getConfiguration().lineHeight and getConfiguration().wrappingInfo to auto-resize the editor, as mentioned in #103 (comment).

@trevorade
Copy link

@alexdima, this issue is blocking our company's ability to upgrade to 0.19.x. Is there any chance of adding back the ability to get the current lineHeight and wrappingInfo for the sake of working around #794? Or do you see Monaco gaining support for auto-height based on content anytime soon?

@trevorade
Copy link

Thanks! Is the plan to include this commit in 0.19.3?

@alexdima
Copy link
Member

@trevorade It is included in 0.19.3

@vscodebot vscodebot bot locked and limited conversation to collaborators Feb 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
editor-api feature-request Request for new features or functionality
Projects
None yet
Development

No branches or pull requests

4 participants