Skip to content

Commit

Permalink
move file decoration provider registration to extension.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
shouples committed Feb 3, 2025
1 parent 3c3bfb3 commit b6161f4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
7 changes: 7 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ import { getTelemetryLogger } from "./telemetry/telemetryLogger";
import { getUriHandler } from "./uriHandler";
import { ResourceViewProvider } from "./viewProviders/resources";
import { SchemasViewProvider } from "./viewProviders/schemas";
import { SEARCH_DECORATION_PROVIDER } from "./viewProviders/search";
import { SupportViewProvider } from "./viewProviders/support";
import { TopicViewProvider } from "./viewProviders/topics";

Expand Down Expand Up @@ -236,6 +237,12 @@ async function _activateExtension(
// ensure our diagnostic collection(s) are cleared when the extension is deactivated
context.subscriptions.push(JSON_DIAGNOSTIC_COLLECTION);

// register the search decoration provider for the tree views so any matches can be highlighted
// with a dot to the right of the item label+description area
context.subscriptions.push(
vscode.window.registerFileDecorationProvider(SEARCH_DECORATION_PROVIDER),
);

// XXX: used for testing; do not remove
return context;
}
Expand Down
14 changes: 2 additions & 12 deletions src/viewProviders/resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,7 @@ import { updateLocalConnection } from "../sidecar/connections/local";
import { ConnectionStateWatcher } from "../sidecar/connections/watcher";
import { DirectConnectionsById, getResourceManager } from "../storage/resourceManager";
import { updateCollapsibleStateFromSearch } from "./collapsing";
import {
filterItems,
itemMatchesSearch,
SEARCH_DECORATION_PROVIDER,
SEARCH_DECORATION_URI_SCHEME,
} from "./search";
import { filterItems, itemMatchesSearch, SEARCH_DECORATION_URI_SCHEME } from "./search";

const logger = new Logger("viewProviders.resources");

Expand Down Expand Up @@ -131,13 +126,8 @@ export class ResourceViewProvider implements vscode.TreeDataProvider<ResourceVie

const listeners = this.setEventListeners();

// register the search decoration provider for the tree view so any matches can be highlighted
// with a dot to the right of the item label+description area
const searchDecorationProvider: vscode.Disposable =
vscode.window.registerFileDecorationProvider(SEARCH_DECORATION_PROVIDER);

// dispose of the tree view and listeners when the extension is deactivated
this.disposables.push(this.treeView, searchDecorationProvider, ...listeners);
this.disposables.push(this.treeView, ...listeners);
}

static getInstance(): ResourceViewProvider {
Expand Down

0 comments on commit b6161f4

Please sign in to comment.