Skip to content

Commit c08ea3f

Browse files
authored
fix: revertTreeString regex (#11)
* fix: revertTreeString regex works with more depth tree-string Support to revert more depth tree-string
1 parent 4c0132f commit c08ea3f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ export function createWebview(context: vscode.ExtensionContext, text = '') {
6767
/** create a revert regexp according to current config, and revert tree-string back */
6868
export function revertTreeString(treeString: string, replaceWith = '#') {
6969
const { child, last, parent, dash, blank } = getCharCodesFromConfig();
70-
// [└├]──|│ {3}| *(?=[└├│])
71-
const reg = new RegExp(`[${last}${child}]${dash}${dash}|${parent}${blank}{3}|${blank}*(?=[${last}${child}${parent}])`, 'gm');
70+
// [└├]──|│ {3}|^( {4})+?|( {4})(?=.*[└├│])
71+
const reg = new RegExp(`[${last}${child}]${dash}${dash}|${parent}${blank}{3}|^(${blank}{4})+?|(${blank}{4})(?=.*[${last}${child}${parent}])`, 'gm');
7272
return treeString.replace(reg, replaceWith);
7373
}
7474

0 commit comments

Comments
 (0)