Skip to content

Commit

Permalink
no need to recreate the same decoration every time
Browse files Browse the repository at this point in the history
  • Loading branch information
shouples committed Feb 3, 2025
1 parent b6c9821 commit 3c3bfb3
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/viewProviders/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,24 @@ export function countMatchingElements(item: ISearchable, searchStr: string): num
return count;
}

/** Decorator for an item in a view that matches a search string. */
const SEARCH_MATCH_DECORATION = new FileDecoration(
"●",
"Matches search",
new ThemeColor("list.highlightForeground"),
);

/** Uri scheme to use when a view's tree item can be decorated to look like a search result. */
export const SEARCH_DECORATION_URI_SCHEME = "search-match";

/**
* File decoration provider that adds a visual indicator to search results for {@link Uri}s using
* the {@link SEARCH_DECORATION_URI_SCHEME}.
*/
export const SEARCH_DECORATION_PROVIDER: FileDecorationProvider = {
provideFileDecoration: (uri: Uri): FileDecoration | undefined => {
if (uri.scheme === SEARCH_DECORATION_URI_SCHEME) {
const decoration = new FileDecoration(
"●",
"Matches search",
new ThemeColor("list.highlightForeground"),
);
decoration.propagate = true;
return decoration;
return SEARCH_MATCH_DECORATION;
}
},
};

0 comments on commit 3c3bfb3

Please sign in to comment.