MCPcopy Create free account
hub / github.com/cursorless-dev/cursorless / findMatchingSnippetDefinition

Function findMatchingSnippetDefinition

src/actions/WrapWithSnippet.ts:167–191  ·  view source on GitHub ↗
(
  typedSelection: TypedSelection,
  definitions: SnippetDefinition[]
)

Source from the content-addressed store, hash-verified

165}
166
167function findMatchingSnippetDefinition(
168 typedSelection: TypedSelection,
169 definitions: SnippetDefinition[]
170) {
171 const languageId = typedSelection.selection.editor.document.languageId;
172
173 return definitions.find(({ scope }) => {
174 if (scope == null) {
175 return true;
176 }
177
178 const { langIds, scopeType } = scope;
179
180 if (langIds != null && !langIds.includes(languageId)) {
181 return false;
182 }
183
184 if (scopeType != null) {
185 // TODO: Implement scope types by refactoring code out of processScopeType
186 throw new Error("Scope types not yet implemented");
187 }
188
189 return true;
190 });
191}

Callers 1

runMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected