Skip to content

Markdown is not auto scrolling. #19898

Closed

Description

@idvorkin
  • VSCode Version: Code 1.9.0 (27240e7, 2017-02-02T08:31:00.827Z)
  • OS Version: Windows_NT ia32 10.0.14393
  • Extensions:
Extension Author Version

Steps to Reproduce:

  1. Open Markdown file
  2. Open preview to side
  3. Scroll in markdown window (preview does not scroll)

Activity

  1. fabiorocha commented on Feb 4, 2017

    @fabiorocha
    Member

    Igor Dvorkin (@idvorkin) This reproes for me as well. It seems to happen only when the file preview is from a file opened from the file system directly and not from a folder currently loaded in the file explorer. For instance, from the picture below:

    image

    README.md opened directly as a file, its preview will not auto scroll.
    generators.md opened from the docs folder, which is loaded in the file explorer, will have its preview auto scroll fine.

    Do you see the same behavior? Probably a path resolution issue.

  2. idvorkin commented on Feb 4, 2017

    @idvorkin
    Author

    Fabio Rocha (@fabiorocha) Good debugging :) I've got the same behavior.

  3. fabiorocha commented on Feb 5, 2017

    @fabiorocha
    Member

    Igor Dvorkin (@idvorkin) awesome. What do you think about updating the issue description (step 3)

    From:
    Scroll in markdown window (preview does not scroll) :(

    To:
    Scroll in preview window (source does not scroll)

    Since it's expected to sync only preview -> source, not the other way around?


    I looked briefly at this today and it seems the problem is on vscode\extensions\markdown\src\extension.ts, in the path comparison made in snippet below

    context.subscriptions.push(vscode.commands.registerCommand('_markdown.revealLine', (uri, line) => {
      const sourceUri = vscode.Uri.parse(decodeURIComponent(uri));
      vscode.window.visibleTextEditors
        .filter(editor => editor.document.uri.path === sourceUri.path)  <---------- ISSUE
        .forEach(editor => {
          const sourceLine = Math.floor(line);
          const text = editor.document.getText(new vscode.Range(sourceLine, 0, sourceLine + 1, 0));
          const fraction = line - Math.floor(line);
          const start = Math.floor(fraction * text.length);
          editor.revealRange(
            new vscode.Range(sourceLine, start, sourceLine + 1, 0),
            vscode.TextEditorRevealType.AtTop);
        });
    }));

    Note the drive letter:

    image

    A simple toUpperCase() on both sides makes this work which proves this is the issue. Obviously this isn't a proper fix for OSs that have a case sensitive file system. It also seems that having the lowercase windows drive letter is by design in many places:

    image

    So I guess a proper fix here would be finding out why editor.document.uri.path doesn't return a normalized path?

  4. idvorkin commented on Feb 5, 2017

    @idvorkin
    Author

    I've updated the description, although both directions should work! Thanks for digging in. By the way, thanks your digging I'm unblocked, and this is a great feature!

  5. mjbvz commented on Feb 6, 2017

    @mjbvz
    Contributor

    Thanks all for the investigation. I've created #20064 which I believe should fix this. As noted, in some Windows scenarios, the drive letter differs between the preview document and the editor document. Using fsPath should fix this. I'm planning to take the fix into the 1.10 insiders builds and also our next 1.9 recovery build

  6. fabiorocha commented on Feb 6, 2017

    @fabiorocha
    Member

    Thanks for the quick fix Matt Bierner (@mjbvz)! I've looked into this a bit more and the root cause is on the way the original source document's URI is created on \vscode\src\vs\base\common\uri.ts

    An else if on "public static file(path: string): URI" would help you avoid all those || on your case and probably prevent other future bugs too.

    else if (URI._upperCaseDrive.test(path)) {
         // windows drive letter: file:///c:/far/boo
         ret._path = path[0].toLowerCase() + path.substr(1);
    } 
  7. mjbvz commented on Feb 6, 2017

    @mjbvz
    Contributor

    Thanks Fabio Rocha (@fabiorocha). That be worth looking into in the future, but I don't want to touch functionality that is so central for this fix. After reviewing the fsPath logic, I think using it should be safe and address the problem. Path casing issues have caused us lots of trouble in the past, so this is an area that we certainly need to revisit but one that can also be pretty finicky

    b4aac1c cherry-picked this workaround into our 1.9 branch to be picked up in the next recovery build

  8. fabiorocha commented on Feb 6, 2017

    @fabiorocha
    Member

    Matt Bierner (@mjbvz) Totally understandable. Thanks again for the quick fix and for the great feature!

  9. locked and limited conversation to collaborators on Nov 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions