| 165 | } |
| 166 | |
| 167 | function 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 | } |