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

Proposed fix for microsoft/vscode-makefile-tools/issues/290 #291

Merged
merged 6 commits into from
Apr 25, 2022

Conversation

jdmchp
Copy link
Contributor

@jdmchp jdmchp commented Mar 11, 2022

As mentioned in issue 290, we would like to propose making the local (to the host) options of debugging and running optional. This makes the vscode-makefile-tools extension friendlier to use with other extensions that allow debugging in embedded systems.
making_local_run_debug_operations_optional

@ghost
Copy link

ghost commented Mar 11, 2022

CLA assistant check
All CLA requirements met.

…ment does not seem to work. Or I am doing something wrong
@@ -103,6 +103,12 @@ export class LaunchTargetNode extends BaseNode {
item.collapsibleState = vscode.TreeItemCollapsibleState.None;
item.tooltip = localize("launch.target.currently.selected.for.debug.run.in.terminal",
"The launch target currently selected for debug and run in terminal.\n{0}", this._toolTip);
// enablement in makefile.outline.setLaunchConfiguration is not
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Trying set this TreeItem to be disabled via enablement in the command: makefile.outline.setLaunchConfiguration

src/tree.ts Outdated Show resolved Hide resolved
extension.getState().configureDirty = true;
updatedSettingsSubkeys.push(subKey);
}

// Final updates in some constructs that depend on more than one of the above settings.
Copy link
Contributor

Choose a reason for hiding this comment

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

I may be wrong, but I think you don't need configureDirty to be true here. Toggling between view or hide the UI elements doesn't need the extension to go through the reconfigure phase. In case you encountered issues which inspired you to write this (as opposed to looking at other similar code above which may have other reasons) let me know. It doesn't hurt but sometimes, for large projects, configure may be very long and we don't want to let it happen without being necessary.

Same question for calling readCurrentLaunchConfiguration. This doesn't take long, even one less reason to insist on removing it, but do you remember whether you needed that call?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

as opposed to looking at other similar code above which may have other reasons)

Yes, basically I followed the pattern without understanding the implications. I will update the PR using your input.
Thanks a lot for the feedback.

src/tree.ts Outdated Show resolved Hide resolved
@andreeis
Copy link
Contributor

andreeis commented Mar 25, 2022

@jdmchp, thank you for taking the time to implement this. I reviewed and left a few comments (to which you responded already). But the most significant suggestion I have is about the new setting. Having the experience of another similar extension based on cmake build technologies, which is a few years older, we ended up needing to show/hide more things, not just the debug UI elements. Instead of adding a new top level setting for each UI element that we may need to hide/show in future, let's follow that pattern of having all the visibility settings encapsulated in one object top level setting, to which we can add in time based on necessities.

The GitHub repository for the CMake Tools VSCode extension is here: https://github.com/microsoft/vscode-cmake-tools. You can follow in package.json and in the typescript sources how settings like "cmake.touchbar.visibility" or "cmake.statusbar.visibility" are defined and used. We don't have a "status bar" concept in the Makefile Tools extension and no "touch bar" special support yet so I imagine you can name the settings collection like "makefile.panel.visibility", with one entry for launch and in future, when somebody will need it, another entry to build (cmake tools extension needed this for debug and build, to hide/show them based on user scenarios that I don't know very well).

Later edit: actually, 3 settings: one for debug, one for run and one for build. Currently you have debug/run together into one setting.

@jdmchp
Copy link
Contributor Author

jdmchp commented Mar 25, 2022

@andreeis ,

let's follow that pattern of having all the visibility settings encapsulated in one object top level setting, to which we can add in time based on necessities.
3 settings: one for debug, one for run and one for build. Currently you have debug/run together into one setting.

Got it. Let me look at the CMake Tools VSCode extension. The pattern of having a single central place to enable/disable functionality makes more sense.

Thanks for the guidance.

@andreeis
Copy link
Contributor

@jdmchp, I forgot to let you know earlier. The CI tests were not hanging because of changes in your PR. I just fixed the problem somewhere in the extension and the fix will get merged in soon.

…al features.

Use OptionalFeatures to handle all optional features in a single place.
If optional feature is controlled via "enablement", then the featute can be
controlled via package.json changes and one change to the optionalFeatures object.
Avoid ѕetting the dirty flag for the configuration when a change of properties is detected.
Minimize operations when changing only flags that control run/debug local features
@jdmchp
Copy link
Contributor Author

jdmchp commented Mar 31, 2022

Hello @andreeis ,
I updated this PR so that multiple optional features can be enabled/disabled by the makefile.panel.visibility property. This property now has an array of optional features that can be toggled. Also, I removed any unnecessary operations (like setting the state's dirty flag). I added two features that can be toggled independently of each other "local debugging" and "local running". I did not make the build feature optional, since to me, the extension's whole point of being is to build. But that could be easily done. If a new feature option is needed to be enabled/disabled and enablement is used to control it, then a change to package.json and a change to this object will be all that is needed.

Thanks for you feedback.

pr_291_single_prop_controls_multiple_features

package.json Outdated
@@ -502,6 +504,27 @@
"default": null,
"description": "%makefile-tools.configuration.makefile.compileCommandsPath.description%",
"scope": "resource"
},
"makefile.panel.visibility": {
"type": "array",
Copy link
Member

Choose a reason for hiding this comment

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

It wasn't immediately obvious to me why this would be an array of objects instead of just an object. Do we need to support an array of objects for this, or will a single object suffice?

Copy link
Contributor Author

@jdmchp jdmchp Mar 31, 2022

Choose a reason for hiding this comment

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

Hello @bobbrow , thanks for the quick reply. My goal is to have a list of features that can be toggled independently of each other. Being a list, I thought of using an array. The goal being able to add optional (toggle-able features) easily. The original PR had a single optional feature (build/debug locally).

Copy link
Member

Choose a reason for hiding this comment

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

An object would be a better representation of what you want. If you do an array of objects, then this would be valid syntax in the settings:

{
   "makefile.panel.visibility": [
    {
      "enableLocalDebugging": false
    },
    {
      "enableLocalDebugging": true
    }
  ]
}

It would be better to just do an object:

{
   "makefile.panel.visibility": {
     "enableLocalDebugging": false
   }
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The use of an array made iterating through the possible different 'option flags' easy. I can refactor to make the makefile.panel.visibility and object and then iterate through its properties instead.
Thanks for the input.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I updated the PR. Using an object makes the code more readable. So, thanks for that suggestion.
pr_291_single_object_controls_multiple_features
I am new to typescript/json. Things flow differently when using java/xml (what I am used to).

…makefile.panel.visibiluty to makefile.optionalFeatures
package.json Outdated
@@ -502,6 +504,22 @@
"default": null,
"description": "%makefile-tools.configuration.makefile.compileCommandsPath.description%",
"scope": "resource"
},
"makefile.optionalFeatures": {
Copy link
Member

Choose a reason for hiding this comment

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

I think the old name makefile.panel.visibility was better. "Optional features" is a bit too vague. And if we copy the pattern from CMake Tools, the individual settings can have simpler names like "debug" and "run" because the context is already understood.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see your point. Let me put that back. Do you think I should have a type in configurations.ts that matches the makefile.panel.visibility exactly:

// as described in makefile.panel.visibility
type MakefilePanelVisibility = {
    enableLocalDebugging: boolean,
    enableLocalRunning: boolean
};

I am not sure what the conventions are. But having an easily relatable name for the type that represents the object that is encapsulated by makefile.panel.visibility makes sense to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK. Changed the property back to makefile.panel.visibility and adjusted types to be relatable to that name.

Copy link
Member

Choose a reason for hiding this comment

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

I'll let @andreeis comment on that. She knows the code better than I do. I tend to chime in more on the stuff that our users would notice like settings, commands, and such.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK. Thanks.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@andreeis , if there is any more work needed on this PR, please let me know. Thanks in advance for your input.

Copy link
Contributor

Choose a reason for hiding this comment

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

@jdmchp, thank you for continuing to work on this. I was out of office, I am going to review and test your updates today.

…ug related to restoring defaults for optional features.
@andreeis
Copy link
Contributor

@jdmchp, I am pushing a commit with the following changes I did:

  • fixed some linter complaints in the new code (anything related with ; or spacing or empty lines, return types, etc...)
  • renamed enableLocalDebugging to debug and enableLocalRunning to run (since name of the parent setting "makefile.panel.visibility" sets the context of these settings that now have smaller name)
  • minor refactoring in tree.ts, since you added updateTree I just called it in other places where we were doing what updateTree does now
  • fixed a bug in src/configuration.ts (updateOptionalFeaturesWithWorkspace) where I found a bug while testing, which I explain in the comment (we were not restoring defaults properly in some case)
  • fixed a bug in the settings update mechanism (src/configuration.ts - initFromStateAndSettings - onDidChangeConfiguration). You forgot to push a new subKey for "makefile.panel.visibility" and we were not tracking the telemetry about settings changes, like for the others.

Additionally, the telemetry was broken for variables like "makefile.name1.name2.name3" etc... and I have PR #309 to fix that. It is separate from your PR.

@jdmchp
Copy link
Contributor Author

jdmchp commented Apr 21, 2022

@andreeis
Thanks for the clean up and the fixes for the 2 bugs (when makefile.panel.visibility is not completely defined, and not pushing the telemetry key). I updated my fork locally and tested too. Looks good.

@andreeis andreeis merged commit eef3c42 into microsoft:main Apr 25, 2022
@andreeis
Copy link
Contributor

@jdmchp, thank you again for implementing this support. It is included in Makefile Tools 0.5.0 which was released today.

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.

3 participants