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

Install ace through npm and use ace beautify #274

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

JannikGM
Copy link
Contributor

Based on #272 which needs to be merged first.
However, also keeping this a draft because it's largely unfinished and untested.

Leaving this here for testing #272 (comment).

@@ -22,25 +25,23 @@ interface IAceEditor {
setReadOnly(readonly: boolean): void;
setShowPrintMargin(show: boolean): void;
}
interface IAceBeautify {
beautify(session: IAceEditorSession): boolean;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ace is actually written in TypeScript and the typings are available in ./node_modules/ace-builds/ace.d.ts and ./node_modules/ace-builds/ace-modules.d.ts, so all of these hacks could be removed.

session.setUseSoftTabs(true);
session.setTabSize(4);
const beautify = ace.require("ace/ext/beautify") as IAceBeautify;
beautify.beautify(session);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Before this runs, the cursor is in line 1, col 1. But after this runs, the editor has no focus / no cursor.

Ideally the cursor would stay where it was using a sourcemap, but ace beautify doesn't seem to allow that.

this.editor.setShowPrintMargin(false);
let timeoutId = -1;
this.editor.setReadOnly(!state.editable && !state.translated);
this.editor.getSession().on("change", (e) => {
session.on("change", (e) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just realized all shaders are editable by default.. why? Is there any feature that benefits from that / uses modified shaders?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes this is one of the most important feature of spector https://github.com/BabylonJS/Spector.js/blob/master/documentation/extension.md#shader-editor :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants