Skip to content

Commit

Permalink
fix: free _checkContentsAreSame
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Jul 15, 2021
1 parent feef034 commit 669f20a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
18 changes: 9 additions & 9 deletions src/CodeFormatManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,6 @@ export default class CodeFormatManager {
}
}

// Checks whether contents are same in the buffer post-format, throwing if
// anything has changed.
_checkContentsAreSame(before: string, after: string): void {
if (before !== after) {
throw new Error("The file contents were changed before formatting was complete.")
}
}

// Return the text edits used to format code in the editor specified.
_formatCodeInTextEditor(editor: TextEditor, range?: Range): Observable<Array<TextEdit>> {
return Observable.defer(() => {
Expand Down Expand Up @@ -270,7 +262,7 @@ export default class CodeFormatManager {
if (edits.length === 0) {
return
}
this._checkContentsAreSame(contents, editor.getText())
_checkContentsAreSame(contents, editor.getText())
// Note that this modification is not in a transaction, so it applies as a
// separate editing event than the character typing. This means that you
// can undo just the formatting by attempting to undo once, and then undo
Expand Down Expand Up @@ -396,3 +388,11 @@ function isBracketPair(typedText: string): boolean {
const validBracketPairs: Array<string> = atom.config.get("bracket-matcher.autocompleteCharacters") as any
return validBracketPairs.includes(typedText)
}

// Checks whether contents are same in the buffer post-format, throwing if
// anything has changed.
function _checkContentsAreSame(before: string, after: string): void {
if (before !== after) {
throw new Error("The file contents were changed before formatting was complete.")
}
}
6 changes: 3 additions & 3 deletions src/legacy-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ export function consumeLegacyProvider(provider: CodeFormatProvider): Disposable
provider.priority =
provider.priority != null
? provider.priority
: // @ts-ignore
: // @ts-ignore
provider.inclusionPriority != null
// @ts-ignore
? provider.inclusionPriority
? // @ts-ignore
provider.inclusionPriority
: 0
if ("formatCode" in provider) {
return consumeRangeProvider(provider)
Expand Down

0 comments on commit 669f20a

Please sign in to comment.