Skip to content

Commit

Permalink
Set selection only when there are changes to apply
Browse files Browse the repository at this point in the history
  • Loading branch information
decaplanet committed Jan 15, 2024
1 parent a88ac38 commit e6a7ecb
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/utils.ts
Expand Up @@ -24,14 +24,15 @@ export class FormattoUtil {
new Notice(error);
}

if (formattedDocument === undefined) return;

editor.setValue(formattedDocument);
editor.setSelection(cursorPosition, cursorPosition);
if (!formattedDocument) return;

if (formattedDocument !== originalDocument) {
editor.setValue(formattedDocument);
editor.setSelection(cursorPosition, cursorPosition);
}
if (
this.plugin.settings.otherOptions.notifyWhenUnchanged &&
originalDocument === editor.getValue()
formattedDocument === originalDocument
) {
new Notice("Document is already formatted!");
} else {
Expand Down

0 comments on commit e6a7ecb

Please sign in to comment.