Skip to content

#84678 add language-specific overrides for breadcrumb and outline settings - #85081

Merged
Johannes Rieken (jrieken) merged 7 commits into
microsoft:masterfrom
pjvan:language-specific-outline-and-breadcrumbs-settings-overrides
Dec 2, 2019
Merged

Johannes Rieken (jrieken) merged 7 commits into
microsoft:masterfrom
pjvan:language-specific-outline-and-breadcrumbs-settings-overrides

Conversation

@pjvan

Copy link
Copy Markdown
Contributor

This PR fixes #84678 by setting the relevant configuration options as overridable and including override details when getting these values from the configuration.

I'm still working on getting the outline settings working the same way, but I'm opening this PR up early for any potential feedback and guidance.

Affected Settings

Affected settings include all of the settings in outline.contribution.tsand breadcrumbs.ts that have a corresponding filteredTypes setting.

Questions / Guidance

  • I'm currently trying to find out how to get the class responsible for filtering outlines OutlineFilter to have the correct context when reading the config. It seems like I either have to include a relevant service codeEditorService or pass OutlineFilter.update the necessary context. Does anyone have any thoughts? Currently leaning towards the former but I don't know the full implications that that might have.

  • When listening for configuration updates in the breadcrumbs model, I'm just checking for changes to configurations with either breadcrumbs or [<current language>] and updating that breadcrumb's outline if those are affected. Is this the way to do it or can I be more specific? It seems like the configuration service can only notify changes from the first layer of the configuration tree.

Testing

I haven't written any tests yet because I'm not sure if features like this are supposed to get them, but I can write some if that would be preferred.

});
}

return this._configurationService.getValue<boolean>(key);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You can use the ITextResourceConfigurationService which makes this a lot simpler

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

How's this? 9d9a99d

@jrieken

Copy link
Copy Markdown
Contributor

r pass OutlineFilter.update the necessary context. Does anyone have any thoughts? Currently leaning towards the former but I don't know the full implications that that might have.

Also use the ITextResourceConfigurationService and inside filter use the OutlineModel.get(element).textModel.uri

@pjvan

Copy link
Copy Markdown
Contributor Author

r pass OutlineFilter.update the necessary context. Does anyone have any thoughts? Currently leaning towards the former but I don't know the full implications that that might have.

Also use the ITextResourceConfigurationService and inside filter use the OutlineModel.get(element).textModel.uri

implementation: 25a1bbb

@pjvan

Pieter Vanderpol (pjvan) commented Nov 19, 2019 •

Copy link
Copy Markdown
Contributor Author

A callback is registered here which refilters the outline tree on config reload. Like the similar logic from BreadcrumbsModel, should we try to figure out what language is being used? I'm not sure where to get this information, or if that even makes sense in this context. A temporary fix would be to always filter on configuration change, but that wouldn't be ideal.

@jrieken

Copy link
Copy Markdown
Contributor

A temporary fix would be to always filter on configuration change, but that wouldn't be ideal.

Ideally we get a better API here but what you could try is e.affectedKeys - it lists all changed keys and you could check for the occurrence of outline in there, e.g search for /$\.?outline\./

@pjvan

Pieter Vanderpol (pjvan) commented Nov 20, 2019 •

Copy link
Copy Markdown
Contributor Author

e.affectedKeys is subject to the same limitation unfortunately, but maybe I could regex outline and language specific sections e.g /(outline|\[\w+\])/
edit: 33d8569

private readonly _uri: URI,
private readonly _editor: ICodeEditor | undefined,
@IConfigurationService private readonly _configurationService: IConfigurationService,
@ITextResourceConfigurationService private readonly _textResourceConfigurationService: ITextResourceConfigurationService,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The "normal" ICOnfigurationService shouldn't be needed anymore and everything should be possible using the text resource based service

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

TextResourceConfigurationService doesn't appear to be a strict superset of ConfigurationService, and unfortunately BreadcrumbsConfig uses one of the unported methods updateValue right here in method BreadcrumbsConfig.updateValue This method is, in turn, bound and used by two breadcrumb configuration options, here and here.

This more directly relates to your other coment on BreadcrumbsControl since the references to updateValue are all in there, but I'm guessing we don't want to have to remove BreadcrumbsConfig as a dependency of either class.

What I have right now definitely isn't the ideal solution though, so I could try to bring TextResourceConfigurationService in line with ConfigurationService either in this PR, or get another pr merged first if this issue is too tangential.

I didn't really check to see if I could just use the one config service though, so thanks for pointing it out!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

That's for the explaining - I learnt something :-). Yeah, the TextResourceConfigService seems to be limiting and causing less pretty code /cc Sandeep Somavarapu (@sandy081). Let's keep the PR free from cleaning that up.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Filed #85884 to enhance ITextResourceConfigService

@IThemeService private readonly _themeService: IThemeService,
@IQuickOpenService private readonly _quickOpenService: IQuickOpenService,
@IConfigurationService private readonly _configurationService: IConfigurationService,
@ITextResourceConfigurationService private readonly _textResourceConfigurationService: ITextResourceConfigurationService,

@jrieken Johannes Rieken (jrieken) Nov 28, 2019 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Don't have two configuration services (see my other comment)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Left a reply over there as well which is relevant here.

@jrieken

Copy link
Copy Markdown
Contributor

This is looking good. @petevdp Can you fix merge conflicts and then I'll bring this in for the Nov release

@pjvan

Pieter Vanderpol (pjvan) commented Nov 29, 2019 •

Copy link
Copy Markdown
Contributor Author

Apologies, this merge is going to be broken... Not sure why I thought it would be a good idea to push this without at least testing it. doh. I'll try to resolve this shortly.

edit: I think everything still works actually. All tests are passing and after manually testing the feature I added, it all works still. Again, if any automated testing should be included, let me know and I'll see what I can do.

this._treeFilter.update();
// This is a temporary solution to try and minimize refilters while
// ConfigurationChangeEvents only provide the first section of the config path.
if (e.affectedKeys.some(key => key.search(/(outline|\[\w+\])/))) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

fyi - this lacks a check for === 0. I will fix this one master after merge.

@jrieken
Johannes Rieken (jrieken) merged commit 574f66e into microsoft:master Dec 2, 2019
@pjvan

Copy link
Copy Markdown
Contributor Author

Thanks for everyone's help!

@pjvan
Pieter Vanderpol (pjvan) deleted the language-specific-outline-and-breadcrumbs-settings-overrides branch December 2, 2019 18:49
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make type filters for outline and breadcrumbs language specific

3 participants