Skip to content

Commit

Permalink
Merge pull request #130 from ayame113/provider-returns-disposable
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya authored Aug 16, 2021
2 parents 8edc1f0 + a2fd212 commit ccf89c8
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { CompositeDisposable, TextEditor } from "atom"
import type { Disposable } from "atom"
import { OutlineView } from "./outlineView"
import type { OutlineProvider } from "atom-ide-base"
import { ProviderRegistry } from "atom-ide-base/commons-atom/ProviderRegistry"
Expand Down Expand Up @@ -56,16 +57,20 @@ export function deactivate() {
// subscriptions.add(busySignalProvider)
// }

export async function consumeOutlineProvider(provider: OutlineProvider) {
subscriptions.add(/* providerRegistryEntry */ outlineProviderRegistry.addProvider(provider))
export function consumeOutlineProvider(provider: OutlineProvider): Disposable {
const prividerDisposable = outlineProviderRegistry.addProvider(provider)
subscriptions.add(/* providerRegistryEntry */ prividerDisposable)

// NOTE Generate (try) an outline after obtaining a provider for the current active editor
// this initial outline is always rendered no matter if it is visible or not,
// this is because we can't track if the outline tab becomes visible suddenly later,
// or if the editor changes later once outline is visible
// so we need to have an outline for the current editor
// the following updates rely on the visibility
await getOutline()
getOutline().catch((err) => {
throw err
})
return prividerDisposable
}

// disposables returned inside onEditorChangedDisposable
Expand Down

0 comments on commit ccf89c8

Please sign in to comment.