-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Support plugin tasks using 'TaskScope.Workspace' #9032
Conversation
this.taskNameResolver, | ||
this.workspaceService, | ||
isMulti, | ||
{ showBorder: showBorder } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor: it can be omitted since the variable has the same name as the option:
{ showBorder: showBorder } | |
{ showBorder } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No longer applicable in the latest commit, I will keep it in mind for next changes, thanks !
e9e23f5
to
37c5582
Compare
Hi @colin-grant-work and @tsmaeder, Regards |
It looks like this is going to conflict pretty massively with this PR and it may be worth a discussion to coordinate approach to task scoping. |
I see that @colin-grant-work and @alvsan09 are working on tasks related area very close, so just a proposal, If it's OK with everybody: the discussion could be started with the reviewing #8917 by @alvsan09 |
@RomanNikitenko, did you mean start reviewing #8917 by @colin-grant-work ? or #9032 by @alvsan09 ? I am opened to both options, mine (#9032 is smaller though), so it depends how we want to proceed, tackle the small or the big one first ? we need to merge a portion of it in any case. Regards |
@alvsan09 After reviewing - if it's OK from your point of view - we could merge #8917. It was my proposal, but it's up to you and @colin-grant-work. thanks! |
Hello @RomanNikitenko and @colin-grant-work, Regards |
37c5582
to
ef7e296
Compare
33ac2ea
to
8a8b052
Compare
Hello @RomanNikitenko and @colin-grant-work, Your comments on this implementation are very welcome ! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me for the most part, with a couple of minor requests.
It seems like the version of the plugin is not right as I don't see any provided workspace tasks in the .gif, the plugin provides three workspace tasks and two folder tasks for the the first root. I have also updated the version to 0.0.10 to validate the version of the example loaded on branch "TaskScope.workspace" https://github.com/alvsan09/vscode-task-provider-example/tree/TaskScope.workspace Questions are very welcome ! |
This looks like it's working as intended. You may want to mention that branch and version in the instructions for testing. |
With the new version of the plugin, everything seems to be working as expected. Very nice! |
Good idea !, Done ! |
Sounds Good !, thanks for looking into it ! :-) |
Hi @colin-grant-work , @RomanNikitenko, @vince-fugnitto , @tsmaeder , Vscode does not save the workspace task in the workspace file but it does it in the first root directory it finds, This implementation in Theia does configure workspace tasks in the workspace file in case of multi root projects, which is kind of expected for workspace tasks, however you don't get to configure them for not multi-root projects although you can still run them. Any thoughts on that? |
Hm... I think it's not very intuitive to find tasks in the theia/packages/task/src/browser/quick-open-task.ts Lines 249 to 251 in 997074c
Here, if you modify the condition in l. 249 to this:
detected workspace-scoped tasks will also appear in the |
After the proposed update from @colin-grant-work, the behavior is now equivalent to vscode, Thanks !! :-) I have pushed a new commit reflecting this change and addressed pending comments. |
Hi @colin-grant-work , |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
About https://github.com/eclipse-theia/theia/pull/9032/files#r586799552
as long as it's coming from the detected task system, it'll have the property scope, and if the user chooses to add it to the configured task system, it'll have a ._scope
I think it makes sense to add such description to the corresponding fields of an interface. It should be really useful for people who work with tasks related area.
wdyt?
a3bc8f4
to
680ff5a
Compare
Hi @RomanNikitenko, I hope you are OK with the additional clarifications. |
Hi @colin-grant-work and @RomanNikitenko, What do you guys think? should we try to follow vscode approach and always save provided workspace tasks under a root folder? |
Hi @colin-grant-work, @RomanNikitenko and @vince-fugnitto, Let me know what you guys think ! |
This falls into a hard category for me of things that VSCode does that don't make a lot of sense. Usually we want to do what VSCode does, but if we distinguish between I see a few of courses of action:
I would favor either (2) or (3) over (1) - I can't see any good reason why workspace should mean a particular folder without the user being able to choose which folder it's going to be. I would favor (3) over (2), but I acknowledge that that would be a departure from VSCode's behavior, and so perhaps not consistent with what plugin creators intend - in particular they may be relying on folder-scoping to supply information about the |
@@ -172,6 +172,11 @@ export class TaskConfigurationManager { | |||
return this.models.get(scope); | |||
} | |||
|
|||
findFirstWorkSpaceFolder(): string | undefined { | |||
const firstWorkSpaceFolder = Array.from(this.models.keys()).find(mScope => typeof mScope === 'string'); | |||
return typeof firstWorkSpaceFolder === 'string' ? firstWorkSpaceFolder : undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should just be able to return the previous line. If nothing is found, the value is undefined
; if something is found, it's guaranteed to pass the typeof ... === 'string'
check because that was one of the find
criteria.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm... you should always try out your own snippets before suggesting them 😉. To get the type inference to accept the code, you have to add an explicit type guard as your return value inside the find
:
Array.from(this.models.keys()).find((mScope): mScope is string => typeof mScope === 'string');
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, I won't be able to submit this change as I have removed the function as pointed out in another comment !
Thanks for the good information, I will keep it in mind for a next time.
It seems like workspace tasks should apply to the whole project regardless of the number of roots, so I think one configured instance would be sufficient, so this would be my last choice. I also like option 3, which relies on the first commit, although your concern is very valid as we may break expectations of the location of the 'cwd'. @vince-fugnitto, @tsmaeder, @RomanNikitenko, if you can please give us your opinion ! |
I agree that one instance should be enough, but I think it should be up to the user to decide where that goes - we shouldn't just stick it in the first workspace root. |
@alvsan09 I believe that we should aim to have better multi-root support and not make the assumption that users want to configure their tasks in the first available root. Based on the docs I believe saving the task under the workspace file would be the best solution, while giving users the possibility to choose from available roots would be a fine alternative as well. |
Based on the options listed under 1), and previous comments from @colin-grant-work and @vince-fugnitto , @colin-grant-work, @tsmaeder and @RomanNikitenko could you please confirm if this is ok to proceed with this option 3. in essence: Commit 1 for this PR reflects the behavior listed as option 3 under comment 1) |
Totally agree. From my point of view it's the best option for the current problem. |
37ff92b
to
14574ba
Compare
* Aligns the TaskScope enum definition with vscode see issue [1] and corresponding schemas for Theia [2] and vscode [3] * Supports processing of task configurations provided by plugins with the scope set to TaskScope.Workspace. * Ignores processing of task configurations provided by plugins with the scope set to TaskScope.Global i.e. User tasks. Fixes: eclipse-theia#7931 [1] eclipse-theia#7931 [2] https://github.com/eclipse-theia/theia/blob/2aa2fa1ab091ec36ef851c4e364b322301cddb40/packages/plugin/src/theia.d.ts#L8637 [3] https://github.com/microsoft/vscode/blob/50f907f0ba9b0c799a7c1d2f28a625bf30041636/src/vs/vscode.d.ts#L5923 Signed-off-by: Alvaro Sanchez-Leon <[email protected]>
14574ba
to
d198a28
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes look good to me 👍
If there is no other feedback I'll merge the pull-request later on during the week 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested the following:
Workspace
andFolder
scoped tasks provided by the test plugin are available fromConfigure Tasks
andRun Task
menu- I'm able to run the provided by test plugin tasks
Workspace
scoped tasks are placed in the workspace config file for amulti-root
workspace when I applyConfigure Task
actionWorkspace
scoped tasks are placed in thetasks.json
file when I applyConfigure Task
action for a notmulti-root
workspaceUser
level tasks are still available for running
It works well for me, thanks!
What it does
Fixes #7931
the scope set to TaskScope.Workspace.
In addition to the general description above.
How to test
References
Review checklist
Reminder for reviewers
Signed-off-by: Alvaro Sanchez-Leon [email protected]