atom-community / atom-community/atom-ide-code-format

Format-on-save action doesn't re-save the buffer?

Open
#22 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
5
Forks
3
PR merge metrics
No merged PRs in 30d

Description

I know this repo is somewhat dormant, but I wanted to check in as a first step:

Suppose you've got a language server that can reformat an entire document on save. This package listens for `onDidSave`, debounces the event, then asks a provider to format the buffer. The edits are applied, and then… [the buffer is not saved to disk again](https://github.com/atom-community/atom-ide-code-format/blob/master/src/CodeFormatManager.ts#L66-L73). The `applyTextEditsToBuffer` function delegates to a library function that explicitly says “the changes will be applied to the buffer but not saved.”

Judging by the specs, I don't _think_ this was intentional behavior. [This spec](https://github.com/atom-community/atom-ide-code-format/blob/master/spec/CodeFormatManager-spec.ts#L98-L115) seems to verify that, when a provider has no edits to suggest, there are no further calls to `TextBuffer::save`; I think the implication there is that a second save _would_ happen if the provider did supply edits, but it's hard to say.

Meanwhile, [this spec](https://github.com/atom-community/atom-ide-code-format/blob/master/spec/CodeFormatManager-spec.ts#L80-L97) verifies that a provider is invoked when an editor is saved, and that the resulting text matches expectations, but it does not check if the buffer is dirty.

If this was merely an oversight, I can submit a PR. If it's intentional behavior, perhaps it could be governed by a config setting? And if this package is unmaintained, that's fine, but I figured I'd ask before forking.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.