MCPcopy Create free account
hub / github.com/UNLINEARITY/Obsidian-CodeSpace / replace

Method replace

src/code_view.ts:353–376  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

351 }
352
353 private replace() {
354 const query = this.getQuery();
355 // Allow empty replacement (delete match) by only requiring a search term.
356 if (!query.search) return;
357
358 const { from, to } = this.view.state.selection.main;
359 const currentText = this.view.state.sliceDoc(from, to);
360
361 // 检查当前选中的文本是否匹配搜索词
362 const isMatch = query.caseSensitive ?
363 currentText === query.search :
364 currentText.toLowerCase() === query.search.toLowerCase();
365
366 if (isMatch) {
367 this.view.dispatch({
368 changes: { from, to, insert: query.replace },
369 selection: { anchor: from, head: from + query.replace.length }
370 });
371 this.findNext();
372 } else {
373 // 如果当前选中的不匹配,先查找下一个匹配项
374 this.findNext();
375 }
376 }
377
378 private replaceAll() {
379 const query = this.getQuery();

Callers 14

setupEventListenersMethod · 0.95
normalizeMountPathMethod · 0.80
suggestMountPathFunction · 0.80
escapeRegexMethod · 0.80
renderListMethod · 0.80
normalizeIgnoredPathMethod · 0.80
refreshFileListMethod · 0.80
stripVaultPrefixFunction · 0.80
extractPathFromCandidateFunction · 0.80

Calls 2

getQueryMethod · 0.95
findNextMethod · 0.95

Tested by

no test coverage detected