actboy168 / vscode-tasks

MIT License
37 stars 14 forks source link

add a function: show visual representation for running tasks #43

Open alexzshl opened 1 year ago

alexzshl commented 1 year ago

For #27 and some suggests from vs extension market.

Considering that some users want the status bar button to have a special display when running tasks to indicate that the corresponding task is running, I have attempted to add this feature. About two years ago, I had a similar plan, but due to some of your concerns, I gave up. Now I have re examined the feasibility of this feature and reviewed the official documentation. I am not sure if this will affect other features of the plugin. I hope you can provide your feedback. Since my last merge request, you have refactored most of the code, and there are some parts that I cannot fully understand. Therefore, I cannot be 100% certain that the code for this price increase will adapt to all scenarios. If possible, perhaps improvements can be made in subsequent work.

About this pull request:

  1. Bind the task with the bar to find the corresponding bar through the task definition
  2. Listen for task start and stop events, find the bar through the binding relationship above, and modify its text to display a dynamic icon
  3. Provide an optional configuration for this function to register or unregister the dispose when the configuration is updated

effect: image

actboy168 commented 1 year ago

I prefer simple implementations like #32.

As I said in #28, adding a running status label will cause the position of the statubar to change. So it should also have a stop state label.

alexzshl commented 1 year ago

I prefer simple implementations like #32.

As I said in #28, adding a running status label will cause the position of the statubar to change. So it should also have a stop state label.

Yes, #32 is indeed more concise because I didn't know before today that the task has an ID, so I had to calculate the jsonstring of the entire task object. If the change in location is indeed a problem, refer to the submission and I think there are some solutions:

  1. Just like this commit, dynamically adding or deleting icons requires users to enable the corresponding configuration to indicate that they accept such results
  2. As you mentioned, maintain an default icon for each bar and replace it when it's running. Of course, if there are user-defined icons on the bar text, this can cause some confusion
  3. Combining 1 and 2, here is a slightly more complex processing logic: if there are no icons in the bar, add a default icon; If the bar text starting with a user-defined icon, dynamically replace it when the task is running

Everything is done to ensure that the position of the button text remains unchanged. Although the effect may not be satisfactory to everyone, controlling whether this feature is effective through configuration will at least not affect the original functionality

actboy168 commented 1 year ago

I have implemented it in https://github.com/actboy168/vscode-tasks/commit/7ef7e1bab90e65a2bb82e9b6f9bb5be67098977b