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

Issues with using omittedFromToc setting on Windows #644

Closed
axxie opened this issue Mar 24, 2020 · 4 comments
Closed

Issues with using omittedFromToc setting on Windows #644

axxie opened this issue Mar 24, 2020 · 4 comments
Labels
Area: Table of contents Pertaining to table of contents (TOC generation and detection, related heading operations). Issue: Bug Res: Fixed Fix is checked in, but it might be a few weeks until a release.

Comments

@axxie
Copy link

axxie commented Mar 24, 2020

I would like to report some issues with using omittedFromToc setting on Windows.

  1. Paths relative to the workspace do not work in omittedFromToc setting on Windows. The extension contains the code that attempts to change portion of the doc.fileName to an empty string for future search using relative path. It uses a string with absolute workspace path and slash character as a search pattern for replace. However, on Windows the doc.fileName contains backslash character, not slash, so the replace does not work. Because of this, the workspace relative paths do not work. The mentioned code is here:
    // If we are not in a workspace (i.e. in a standalone file), use the absolute path.
    // Otherwise, use the workspace relative path.
    const currentPath = docWorkspace
    ? doc.fileName.replace(`${docWorkspace.uri.fsPath}/`, '')
    : doc.fileName;
  2. The replace and search in the settings is case-sensitive. However, the paths on Windows are mostly case-insensitive.

For now, the only way to use omittedFromToc setting on Windows is to use absolute paths and use non-capital character for drive letter (the first one in path), like this:

{
    "settings": {
        "markdown.extension.toc.omittedFromToc": {
            "c:\\MyProjects\\project\\README.md": [
                "## Table of contents"
            ]
        }
    }
}
yzhang-gh pushed a commit that referenced this issue Mar 24, 2020
@yzhang-gh
Copy link
Owner

Thanks for your suggestion. It should be fixed in the dev build.

@yzhang-gh yzhang-gh added Area: Table of contents Pertaining to table of contents (TOC generation and detection, related heading operations). Issue: Bug Res: Fixed Fix is checked in, but it might be a few weeks until a release. labels Mar 24, 2020
yzhang-gh pushed a commit that referenced this issue Mar 24, 2020
@i-keliukh
Copy link

Thanks for your suggestion. It should be fixed in the dev build.

I checked the fix.

  1. The issue with drive letter is fixed.
  2. The issue with relative path is not fixed.

The reason is still slash character in the replace:

let currentPath = docWorkspace
? doc.fileName.replace(`${docWorkspace.uri.fsPath}/`, '')
: doc.fileName;

doc.filename contains backslashes, not slashes, so replace cannot find the workspace path with slash.

yzhang-gh pushed a commit that referenced this issue Mar 27, 2020
@yzhang-gh
Copy link
Owner

Thanks!

I was trying to patch this part of code which came from a PR 😂. I have reworked it and now it should work better.

@i-keliukh
Copy link

I confirm that the issue is fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Table of contents Pertaining to table of contents (TOC generation and detection, related heading operations). Issue: Bug Res: Fixed Fix is checked in, but it might be a few weeks until a release.
Projects
None yet
Development

No branches or pull requests

3 participants