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

Method updateUserSnippets

src/core/Snippets.ts:100–127  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

98 }
99
100 async updateUserSnippets() {
101 const snippetFiles = this.userSnippetsDir
102 ? await walkFiles(this.userSnippetsDir)
103 : [];
104
105 const maxSnippetMtime =
106 max(
107 (await Promise.all(snippetFiles.map((file) => stat(file)))).map(
108 (stat) => stat.mtimeMs
109 )
110 ) ?? 0;
111
112 if (maxSnippetMtime <= this.maxSnippetMtimeMs) {
113 return;
114 }
115
116 this.maxSnippetMtimeMs = maxSnippetMtime;
117
118 this.userSnippets = mergeStrict(
119 ...(await Promise.all(
120 snippetFiles.map(async (path) =>
121 JSON.parse(await readFile(path, "utf8"))
122 )
123 ))
124 );
125
126 this.mergeSnippets();
127 }
128
129 /**
130 * Allows extensions to register third-party snippets. Calling this function

Callers 2

constructorMethod · 0.95
initMethod · 0.95

Calls 3

mergeSnippetsMethod · 0.95
walkFilesFunction · 0.90
mergeStrictFunction · 0.90

Tested by

no test coverage detected