Add If then else in json schema for conditional logic #15675

Closed
opened 2026-01-31 04:45:12 +00:00 by claunia · 4 comments
Owner

Originally created by @Joel-Nickson on GitHub (Oct 24, 2021).

Description of the new feature/enhancement

It would be nice to have conditions in json as defined in json-schema.org

Proposed technical implementation details (optional)

settings.json
...
"if":{"startingDirectory": "C:\\WINDOWS\\system32"},
"then":{"startingDirectory": "%USERPROFILE%\\Desktop"},
"else":{"startingDirectory": "."},
...

Problem:

  • I have set the "startingDirectory": "." in the settings.json for now. In that case the
    wt starts up at "C:\WINDOWS\system32" if i start the terminal from the start Menu or using an Autohot-key or any other app that can create an instance of the wt (like opening from cmd or from sublime-text),
    and if I right click on a folder and open the terminal then I get the terminal in the current directory of the folder.

  • And if I set the "startingDirectory": "C:\Users\\Desktop" then I get the terminal in that directory always(except on opening using menubar in a folder) even if I want to open it on a current folder sometimes

Other use cases:

  • increase the size of the terminal when using the split-pane actions maybe like
"when": {"command": {"action":"splitPane"}},
"then":["initialCols": 180,"initialRows": 30]
  • or changing the background of the window based on the current time(if it was possible to read system time or any how)
Originally created by @Joel-Nickson on GitHub (Oct 24, 2021). <!-- 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 I ACKNOWLEDGE THE FOLLOWING BEFORE PROCEEDING: 1. If I delete this entire template and go my own path, the core team may close my issue without further explanation or engagement. 2. If I list multiple bugs/concerns in this one issue, the core team may close my issue without further explanation or engagement. 3. If I write an issue that has many duplicates, the core team may close my issue without further explanation or engagement (and without necessarily spending time to find the exact duplicate ID number). 4. If I leave the title incomplete when filing the issue, the core team may close my issue without further explanation or engagement. 5. If I file something completely blank in the body, the core team may close my issue without further explanation or engagement. All good? Then proceed! --> # Description of the new feature/enhancement It would be nice to have conditions in json as defined in [json-schema.org](https://json-schema.org/understanding-json-schema/reference/conditionals.html#if-then-else) <!-- A clear and concise description of what the problem is that the new feature would solve. Describe why and how a user would use this new functionality (if applicable). --> # Proposed technical implementation details (optional) ```json settings.json ... "if":{"startingDirectory": "C:\\WINDOWS\\system32"}, "then":{"startingDirectory": "%USERPROFILE%\\Desktop"}, "else":{"startingDirectory": "."}, ... ``` Problem: - I have set the "startingDirectory": "." in the settings.json for now. In that case the wt starts up at "C:\\WINDOWS\\system32" if i start the terminal from the start Menu or using an Autohot-key or any other app that can create an instance of the wt (like opening from cmd or from sublime-text), and if I right click on a folder and open the terminal then I get the terminal in the current directory of the folder. - And if I set the "startingDirectory": "C:\\Users\\<user>\\Desktop" then I get the terminal in that directory always(except on opening using menubar in a folder) even if I want to open it on a current folder sometimes <!-- A clear and concise description of what you want to happen. --> Other use cases: - increase the size of the terminal when using the split-pane actions maybe like ```json "when": {"command": {"action":"splitPane"}}, "then":["initialCols": 180,"initialRows": 30] ``` - or changing the background of the window based on the current time(if it was possible to read system time or any how)
Author
Owner

@Joel-Nickson commented on GitHub (Oct 25, 2021):

Sadly, I am not a developer from ms.
This issue will be tracked by the bot and then will be reviewed by the maintainers or developers and they have the power to assign this to you, not me.
If you know know what you need to do then I am sure you can work on it once they approve.

@Joel-Nickson commented on GitHub (Oct 25, 2021): Sadly, I am not a developer from ms. This issue will be tracked by the bot and then will be reviewed by the maintainers or developers and they have the power to assign this to you, not me. If you know know what you need to do then I am sure you can work on it once they approve.
Author
Owner

@zadjii-msft commented on GitHub (Oct 25, 2021):

@Joel-Nickson Is this not something that the commandline wt -d .would solve? I'd worry about adding a lot of potential complexity here. This sounds like something that'd be neigh-impossible to hook up to the settings UI in a reasonable fashion.

increase the size of the terminal when using the split-pane actions

This sounds like a good use case for the multipleActions action (new in 1.12), combined with the setWindowPos action (which is on my personal backlog but I don't think I filed anywhere)

changing the background of the window based on the current time(if it was possible to read system time or any how)

Now, that one doesn't have a good alternate solution, but feels like a good extension idea (#4000)

@zadjii-msft commented on GitHub (Oct 25, 2021): @Joel-Nickson Is this not something that the commandline `wt -d .`would solve? I'd worry about adding a _lot_ of potential complexity here. This sounds like something that'd be neigh-impossible to hook up to the settings UI in a reasonable fashion. > increase the size of the terminal when using the split-pane actions This sounds like a good use case for the `multipleActions` action (new in 1.12), combined with the `setWindowPos` action (which is on my personal backlog but I don't think I filed anywhere) > changing the background of the window based on the current time(if it was possible to read system time or any how) Now, that one doesn't have a good alternate solution, but feels like a good extension idea (#4000)
Author
Owner

@Joel-Nickson commented on GitHub (Oct 25, 2021):

multipleActions action (new in 1.12), combined with the setWindowPos action

I can't wait for the wt v1.12 then

Is this not something that the commandline wt -d . would solve?

and yes, that solved my problem 1

@Joel-Nickson commented on GitHub (Oct 25, 2021): > `multipleActions` action (new in 1.12), combined with the `setWindowPos` action I can't wait for the wt v1.12 then > Is this not something that the commandline wt -d . would solve? and yes, that solved my problem 1
Author
Owner

@zadjii-msft commented on GitHub (Oct 26, 2021):

Glad to hear it! I'm gonna close this for now since the underlying problem is solved. If we come up with more elaborate use cases, and a more well-defined design, we can reopen in the future. Thanks!

@zadjii-msft commented on GitHub (Oct 26, 2021): Glad to hear it! I'm gonna close this for now since the underlying problem is solved. If we come up with more elaborate use cases, and a more well-defined design, we can reopen in the future. Thanks!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#15675