Open bbo2adwuff opened 3 years ago
Well a first try could be something along these lines?
private async onSaveEditor(
context: DocumentRegistry.IContext<IEditorTracker>,
state: DocumentRegistry.SaveState
) {
if (state === 'started' && this.config.formatOnSave) {
await this.fileEditorCodeFormatter.formatAction(this.config, 'black');
}
}
But where to call it? Because here at https://github.com/wallneradam/jupyterlab-trailing-space-remover/blob/master/src/index.ts they seem to have one createNew
in the class RemoveTrailingSpaceEditor
and one in class RemoveTrailingSpaceNotebook
.
Sorry for the late reply, I haven't given this project much love, I just kinda lost steam over the years as I got increasingly burnt out, but lately I have gotten a second wind (perhaps only for a brief period...)
FWIW I am in middle to a big refactor for the project (mostly due to the evolution of jupyterlab's plugin tooling), this would be one of the things I can look at after that.
Without the the refactor, the development envrionment for this plugin is just nightmare-ish to use, so that is currently trumping all tasks.
Checklist prior to opening an issue
Describe the feature request Auto format code when saving a notebook works like a charm since the merge of https://github.com/ryantam626/jupyterlab_code_formatter/pull/195
So this is rather a feature request, but when I open a
.py
file in JupyterLab it would be great to also have theformatOnSave
option.Do you think along the following lines it would be possible to also use the formatter for the py file editor? https://github.com/ryantam626/jupyterlab_code_formatter/blob/ac5fbd1e2d0b3f031763743e53558dba74d7380a/src/index.ts#L107-L114