Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support configuring the indent to use tab rather than 2 spaces #421

Closed
zhao414 opened this issue Jul 17, 2022 · 2 comments
Closed

Support configuring the indent to use tab rather than 2 spaces #421

zhao414 opened this issue Jul 17, 2022 · 2 comments

Comments

@zhao414
Copy link

zhao414 commented Jul 17, 2022

Is your feature request related to a problem? Please describe.
The command Breadcrumbs: Copy a Local Index to the clipboard will generate a hierarchical list.
The indent used in this hierarchical list is the space, i.e. adding 2 spaces increases a level of indent.

However, in the obsidian, the indent used for hierarchical list is configurable. And in my case, the indent used is the tab, i.e. adding 1 tab will increase 1 level of indent.

Therefore, here comes the problem, when I generate a long list with Breadcrumbs, I need to manually replace the indent of almost every item from 2 spaces to 1 tab.

Describe the solution you'd like
A configuration is preferred, so the user can choose the indent that they need.

Describe alternatives you've considered
alt 1. find and replacement performed manually.
alt 2. manually patch the main.js

function createIndex(allPaths, asWikilinks) {
    let index = "";
    const copy = lodash.cloneDeep(allPaths);
    const reversed = copy.map((path) => path.reverse());
    reversed.forEach((path) => path.shift());
    const indent = ".."; //patch this line with: const indent = "\t";
    const visited = {};
    reversed.forEach((path) => {
        for (let depth = 0; depth < path.length; depth++) {
            const currNode = path[depth];
            // If that node has been visited before at the current depth
            if (visited.hasOwnProperty(currNode) &&
                visited[currNode].includes(depth))
                continue;
            else {
                index += `${indent.repeat(depth)}- ${asWikilinks ? makeWiki(currNode) : currNode}\n`;
                if (!visited.hasOwnProperty(currNode))
                    visited[currNode] = [];
                visited[currNode].push(depth);
            }
        }
    });
    return index;
}

Additional context
no

@SkepticMystic
Copy link
Owner

I like this idea :)
I've added a setting under BC Settings > Commands > Create Index >Indent Character(s). Let me know your experience with it

@zhao414
Copy link
Author

zhao414 commented Aug 1, 2022

The new feature is great, thanks!

@zhao414 zhao414 closed this as completed Aug 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants