Skip to content

Commit

Permalink
fix: add getProviderForEditorQuick
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Oct 4, 2020
1 parent 6e17c17 commit 99a430c
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src-commons-atom/ProviderRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ export class ProviderRegistry {
}
}

getProviderForEditorQuick(editor: TextEditor): Provider | undefined {
const grammar = editor.getGrammar().scopeName
return this.findProviderQuick(grammar)
}

// TODO deprecate since there can be N providers.
getProviderForEditor(editor: TextEditor): Provider | null {
const grammar = editor.getGrammar().scopeName
Expand All @@ -45,6 +50,12 @@ export class ProviderRegistry {
return this.findAllProviders(grammar)
}

findProviderQuick(grammar: string): Provider | undefined {
return this.providers.find((provider) => {
provider.grammarScopes?.includes(grammar)
})
}

findProvider(grammar: string): Provider | null {
for (const provider of this.findAllProviders(grammar)) {
return provider
Expand Down

0 comments on commit 99a430c

Please sign in to comment.