Configurable port for Editor HTTP API
Editor HTTP API is a great solution especially for 3rd party IDE integrations. I would like to use it with Sublime Text(or vscode)
Currently its port is random and there is only way to get the random port of the Editor's http-server is by looking at console output. There is a workaround, but it is problematic and it is not a proper solution.
it would be perfect, if the port number can be configured from editor’s preference window or before the Editor lauch(maybe by passing a param to Editor). But of course it requires a port check before starting http-server. If the port is in use it might use a random port
Taking into account that the user may have multiple editors running, I don't think it's the best solution to have a single predefined port in the preferences.
Isn't it a common practice to write a randomly generated port into a file at runtime so that local services know how to communicate?
In our case, it could be a file in the build or .internal folder, like:
project/build/*
or
project/.internal/*
with a filename such as port, editor_port, or editor_service.
Taking into account that the user may have multiple editors running, I don't think it's the best solution to have a single predefined port in the preferences.
Fair point, can't argue.
with a filename such as
port,editor_port, oreditor_service.
Yes, why not. In this case IDE(Sublime Text, vsCode etc) can read this file from this folder and set it. But the problem of multiple editor is still exist. How do we know which editor is using which port(or do we have to know)....
Yes, why not. In this case IDE(Sublime Text, vsCode etc) can read this file from this folder and set it. But the problem of multiple editor is still exist. How do we know which editor is using which port(or do we have to know)....
Not sure if it makes sense to have two editors running for the same project, so if editor saves port into the project folder - it's unique for that session with the project.
Not sure if it makes sense to have two editors running for the same project
I don't think that is a use-case we should cater to.
The file /.internal/editor-port could also contain multiple lines if you have multiple editors open.
I like the solution, it would make it possible to execute a build command from VSCode for us. 👍
I also using external (vim). It would be great if i can trigger reload with http request, so when the file is saved, on_reload can be called.
I also using external (vim). It would be great if i can trigger reload with http request, so when the file is saved, on_reload can be called. Please check https://github.com/defold/defold/blob/dev/editor/doc/http-api.md
@vlaaad @AGulev I develop a small Sublime Text extension and works great so far. Thank you all
@vlaaad @AGulev I develop a small Sublime Text extension and works great so far. Thank you all
Oh, I'd like to know more about this! Can you share something yet?
Thanks for this! 👍 I'll get working on a VSCode extension at some point. 😁
Thanks for this! 👍 I'll get working on a VSCode extension at some point. 😁
As I know it's already exist and buil using editor API, the only downside that it parse port from the editor logs
Oh, I'd like to know more about this! Can you share something yet?
@britzl It is extremely primitive and can’t handle edge cases. Any “vibe coder” could do a better job :) It just checks the .internal/editor-port file in the project folder when the project is opened (instead, the file should be watched), then adds a port variable and calls the commands(build, hotreload) using curl. I might prepare a proper extension if I get the time and share it…
Just a note, the file is called .internal/editor.port
https://defold.com/manuals/editor/#editor-server