Skip to content

Make canonical Windows paths more canonicals#1254

Merged
voodoos merged 2 commits intoocaml:masterfrom
voodoos:fix-windows-path
Feb 5, 2021
Merged

Make canonical Windows paths more canonicals#1254
voodoos merged 2 commits intoocaml:masterfrom
voodoos:fix-windows-path

Conversation

@voodoos
Copy link
Copy Markdown
Collaborator

@voodoos voodoos commented Feb 2, 2021

These changes ensure that the / or \ in the drive part of a Windows path (c:\) is correctly converted to the current platform separator.

It also always make the drive letter uppercase. This seems to be the standard (even if Windows understand both) and matches Sys.getcwd () style.

This fixes communication issues between Merlin and Dune's ocaml-merlin configuration server on WIndows.

Todo

  • Propagate to 411
  • Propagate to 412

@nojb
Copy link
Copy Markdown
Contributor

nojb commented Feb 2, 2021

It also always make the drive letter uppercase. This seems to be the standard (even if Windows understand both) and matches Sys.getcwd () style.

Note that the case of Sys.getcwd () is not well-defined. Recently we fixed a similar problem in dune and made the opposite choice (lowercase) ocaml/dune#3966

Printf.sprintf "%s%s"
(String.sub dir ~pos:0 ~len:2 |> String.uppercase_ascii)
Filename.dir_sep
else dir
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only normalizes the backslash following the drive letter. Are we sure this is enough? I would have thought that under Windows we should normalize all slashes. I will try it and report back.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other slashes were already normalized as expected: split_path returns a list of path segments which are concatenated back using Filename.concat.

@voodoos
Copy link
Copy Markdown
Collaborator Author

voodoos commented Feb 3, 2021

It also always make the drive letter uppercase. This seems to be the standard (even if Windows understand both) and matches Sys.getcwd () style.

Note that the case of Sys.getcwd () is not well-defined. Recently we fixed a similar problem in dune and made the opposite choice (lowercase) ocaml/dune#3966

So it it is a very recent change, that is why in your example the detected workspace root is still capitalized.

@voodoos
Copy link
Copy Markdown
Collaborator Author

voodoos commented Feb 5, 2021

@trefis while Dune 2.9 is not release it is not obvious to determine if the drive letter should be capitalized or not. I added a revolting hack c8bf493 to retry loading the configuration with an uppercased drive letter when failing.

@trefis trefis changed the base branch from 3.4 to master February 5, 2021 14:19
@voodoos voodoos force-pushed the fix-windows-path branch 2 times, most recently from 7c6170a to 2e0fe57 Compare February 5, 2021 14:47
@voodoos voodoos merged commit f336e62 into ocaml:master Feb 5, 2021
voodoos added a commit to voodoos/merlin that referenced this pull request Feb 5, 2021
* Use system separator after drive letter
voodoos added a commit to voodoos/merlin that referenced this pull request Feb 5, 2021
* Use system separator after drive letter
voodoos added a commit to voodoos/merlin that referenced this pull request Feb 5, 2021
* Use system separator after drive letter
trefis added a commit to trefis/opam-repository that referenced this pull request Feb 16, 2021
CHANGES:

Tue Feb 16 10:33:11 AM CET 2021

  + merlin binary:
    - fix windows paths canonicalization (ocaml/merlin#1254)
    - fix hanging on windows (ocaml/merlin#1256, ocaml/merlin#1263)
trefis added a commit to trefis/opam-repository that referenced this pull request Feb 16, 2021
CHANGES:

Tue Feb 16 10:33:11 AM CET 2021

  + merlin binary:
    - fix windows paths canonicalization (ocaml/merlin#1254)
    - fix hanging on windows (ocaml/merlin#1256, ocaml/merlin#1263)
trefis added a commit to trefis/opam-repository that referenced this pull request Feb 16, 2021
CHANGES:

Tue Feb 16 10:33:11 AM CET 2021

  + merlin binary:
    - fix windows paths canonicalization (ocaml/merlin#1254)
    - fix hanging on windows (ocaml/merlin#1256, ocaml/merlin#1263)
trefis added a commit to trefis/opam-repository that referenced this pull request Feb 16, 2021
CHANGES:

Tue Feb 16 10:33:11 AM CET 2021

  + merlin binary:
    - fix windows paths canonicalization (ocaml/merlin#1254)
    - fix hanging on windows (ocaml/merlin#1256, ocaml/merlin#1263)
trefis added a commit to trefis/opam-repository that referenced this pull request Feb 16, 2021
CHANGES:

Tue Feb 16 10:33:11 AM CET 2021

  + merlin binary:
    - fix windows paths canonicalization (ocaml/merlin#1254)
    - fix hanging on windows (ocaml/merlin#1256, ocaml/merlin#1263)
trefis added a commit to trefis/opam-repository that referenced this pull request Feb 16, 2021
CHANGES:

Tue Feb 16 10:33:11 AM CET 2021

  + merlin binary:
    - fix windows paths canonicalization (ocaml/merlin#1254)
    - fix hanging on windows (ocaml/merlin#1256, ocaml/merlin#1263)
trefis added a commit to trefis/opam-repository that referenced this pull request Feb 16, 2021
CHANGES:

Tue Feb 16 10:33:11 AM CET 2021

  + merlin binary:
    - fix windows paths canonicalization (ocaml/merlin#1254)
    - fix hanging on windows (ocaml/merlin#1256, ocaml/merlin#1263)
trefis added a commit to trefis/opam-repository that referenced this pull request Feb 16, 2021
CHANGES:

Tue Feb 16 10:33:11 AM CET 2021

  + merlin binary:
    - fix windows paths canonicalization (ocaml/merlin#1254)
    - fix hanging on windows (ocaml/merlin#1256, ocaml/merlin#1263)
voodoos added a commit to voodoos/opam-repository that referenced this pull request Apr 13, 2021
CHANGES:

Tue Apr 12 11:44:22 AM CET 2021

  + merlin binary
    - external configuration reading:
      + use relative paths to communicate with Dune when possible. This solves
        issues related to symlinks on Unix and improve Windows support (ocaml/merlin#1271,
        fixes ocaml/merlin#1288)
      + make the `workdir` configuration value when using the
        `dune ocaml-merlin` configuration provider the same as when using
        `dot-merlin-reader` so that ppxes behaves in the same way as before
        (ocaml/merlin#1284, fixes ocaml/dune#4479, discussion in ocaml/merlin#1292)
    - destruct:  make the destruct command more resilient to ill-typed
      expressions and when called without nodes (ocaml/merlin#1304, fixes ocaml/merlin#1300)
    - Mppx: don't restore cookies after invocation. Ppx are invoked only once
      so there is no need to manage cookies. This small change should increase
      performance and should not change any other behavior (ocaml/merlin#1309)
    - windows:
      + system command variant: do not open a window console when
        launching a ppx (ocaml/merlin#1270, fixes ocaml/merlin#714)
      + fix Emacs hanging when starting Merlin (ocaml/merlin#1263)
      + fix path canonicalization (ocaml/merlin#1254)
    - fix same file documentation bug (ocaml/merlin#1265 by @ulugbekna, fixes ocaml/merlin#1261)
  + editor modes
    - emacs:
      + modernization of the elisp code and conformance with coding
        guidelines (ocaml/merlin#1247, ocaml/merlin#1310 by Steve Purcell )
      + use opam var where applicable (ocaml/merlin#1310)
      + fix "wrong number of argument" (ocaml/merlin#1250 by @atharvashukla, fixes ocaml/merlin#1234)
      + fix for Neovim's CursorMoved semantics (ocaml/merlin#1213 by @ddickstein)
    - vim & emacs : new client-side "merlin use package" commands, restoring
      previous behavior (ocaml/merlin#1272, fixes ocaml/merlin#1191)
  + test suite
    - cover the document fix (ocaml/merlin#1265, ocaml/merlin#1315)
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

Successfully merging this pull request may close these issues.

2 participants