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

Allow using workspaceFolder placeholder variable for more portable sandbox configurations #424

Merged
merged 5 commits into from
Nov 7, 2020

Conversation

mnxn
Copy link
Collaborator

@mnxn mnxn commented Nov 1, 2020

Closes #374

Allows using ${workspaceFolder} for the sandbox setting's manifest/switch/template. Since this only replaces the variable, it's done during the JSON serialization/deserialization. Relative paths are still not supported, so no command execution logic was changed.

In a workspace editor, it resolves ${workspaceFolder} with the path of the first workspace folder. If no workspace folders are open, ${workspaceFolder} is resolved with the value of Process.cwd.

When selecting a sandbox, if the path of the workspace folder appears in a discovered configuration, it will be substituted with ${workspaceFolder}. This makes the sandbox configurations portable by default.

@mnxn mnxn requested a review from rgrinberg November 1, 2020 22:49
src/settings.mli Outdated Show resolved Hide resolved
@mnxn mnxn force-pushed the sandbox-path-variable branch from 5d83d93 to 0dcafde Compare November 2, 2020 21:44

type replacer = string -> string list -> string

val replace : string -> regexp:t -> replacer:replacer -> string
Copy link
Contributor

Choose a reason for hiding this comment

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

Surprised that this binding doesn't exist in jsoo. You should consider contributing it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This function is difficult to type correctly. It includes a variable number of string parameters with different parameter types after that: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace#Specifying_a_function_as_a_parameter

Now that I've revisited it, I think this binding is unsafe due to the trailing parameters that were omitted.

I'll try to contribute it to Js_of_ocaml if I can get a gen_js_api version working first.

@mnxn mnxn requested a review from rgrinberg November 3, 2020 00:27
@mnxn mnxn force-pushed the sandbox-path-variable branch from c708ec7 to 515c3dc Compare November 7, 2020 00:54
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.

settings.json::ocaml.sandbox.root written with absolute path vs relative path breaks project portability
2 participants