Skip to content

Move away from lineWarningLength into validationProvider#42206

Merged
joaomoreno merged 2 commits intomasterfrom
joao/scm-input-validation-provider
Jan 30, 2018
Merged

Move away from lineWarningLength into validationProvider#42206
joaomoreno merged 2 commits intomasterfrom
joao/scm-input-validation-provider

Conversation

@joaomoreno
Copy link
Member

@joaomoreno joaomoreno commented Jan 26, 2018

As discussed, here's another approach to fix #21144

This solution exposes a validationProvider on the SCM input, instead of relying on a very specific lineWarningLength property. It is a more general solution to the problem, which feels better on the API side of things.

There are a few drawbacks, though:

  • It requires renderer <-> ext host communication while there is interaction with the scm input (though debounced).
  • The overall feeling isn't great. The UI seems slow, given the debouncing.
  • Opens up quite a bit more API.

@jrieken Please review the approach in the API and, given the drawbacks, let me know if this is still your preferred approach.

@joaomoreno joaomoreno added api git GIT issues scm General SCM compound issues labels Jan 26, 2018
@joaomoreno joaomoreno added this to the February 2018 milestone Jan 26, 2018
@joaomoreno joaomoreno self-assigned this Jan 26, 2018
@joaomoreno joaomoreno requested a review from jrieken January 26, 2018 15:47
* @return A human readable string which is presented as diagnostic message.
* Return `undefined`, `null`, or the empty string when 'value' is valid.
*/
validateInput(value: string, cursorPosition: number): ProviderResult<SourceControlInputBoxValidation | undefined | null>;
Copy link
Member

Choose a reason for hiding this comment

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

Providers usually have a provide method, esp. when returning a ProviderResult. And you also wanna take a look at that type to learn why you don't need undefined | null here...

* the validation provider simply by setting this property to a different value.
*/
lineWarningLength: number | undefined;
validationProvider: SourceControlInputBoxValidationProvider;
Copy link
Member

Choose a reason for hiding this comment

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

Yeah, maybe... It doesn't fill well into the provider approach which usually is about registering multiple providers, like registerInputBoxValidationProvider('git', myProviderInstance). I'd say make it a real provider or let be a simple callback.

@jrieken
Copy link
Member

jrieken commented Jan 26, 2018

The simplified (maybe over-simpilied?), down-to-earth, variant is this: InputBoxOptions#validateInput?(value: string): string | undefined | null | Thenable<string | undefined | null>;

@joaomoreno
Copy link
Member Author

joaomoreno commented Jan 26, 2018

@jrieken I initially went with that approach and gave up on it given the lack of precedence. I feel it is not so obvious that one could set that property, since it is a function, you know?

@jrieken
Copy link
Member

jrieken commented Jan 26, 2018

Yeah, it is JavaScript'ish but yeah, not commonly used in our API... Lets talk on Monday

@joaomoreno
Copy link
Member Author

@jrieken Did the changes we talked about:

  • settable function
  • moved to proposed

@joaomoreno joaomoreno merged commit 7b9368e into master Jan 30, 2018
@joaomoreno joaomoreno deleted the joao/scm-input-validation-provider branch January 30, 2018 18:38
@github-actions github-actions bot locked and limited conversation to collaborators Mar 31, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

api git GIT issues scm General SCM compound issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Git commit box does not warn long messages

2 participants