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
base: master
Are you sure you want to change the base?
Conversation
@@ -22,25 +25,23 @@ interface IAceEditor { | |||
setReadOnly(readonly: boolean): void; | |||
setShowPrintMargin(show: boolean): void; | |||
} | |||
interface IAceBeautify { | |||
beautify(session: IAceEditorSession): boolean; | |||
} |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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) => { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 :-)
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).