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

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

Offen
#22 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
TypeScript
Sterne
5
Forks
3
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

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.

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Untersuche src/CodeFormatManager.ts rund um den onDidSave-Ablauf und applyTextEditsToBuffer und lies anschließend die zugehörigen Fälle in spec/CodeFormatManager-spec.ts in den Zeilen 80-115. Überprüfe, ob das Anwenden von Provider-Edits den Buffer als dirty hinterlässt und ob ein zweites TextBuffer::save erwartet wird; abgeschlossen ist die Aufgabe, wenn das Verhalten durch Specs abgedeckt ist und der beabsichtigten Save-Semantik entspricht.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
typescript
Bereich
tooling
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.