Closed JustinGrote closed 3 years ago
I've added the following api
export interface SourceControlInputBox {
/**
* Sets focus to the input.
*/
focus(): void;
}
Notes from api sync:
Can we use the workbench.scm.focus
command?
Instead of focus
, maybe show(preserveFocus: boolean)
- Can we use the
workbench.scm.focus
command?
workbench.scm.focus
consistently does the wrong thing and focuses staged files (after staging) when using the workbench.scm.focus
command and friends. That behavior obviously should be changed, though. Biting the bullet and exposing a command that literally says to focus the field itself is likely a better, more explicit option in the end. "Focus Source Control" as a command left the door open for the terrible default behavior we have now.
@JustinGrote @GoNZooo Can you provide some use-cases for needing this method? In the cases where I want it, I actually only want the focus as a side-effect of showing a validation message on the input itself (which is another api I'm thinking about).
I can also look into why workbench.scm.focus
isn't consistent
I want a command to focus on the input because it's my most common reason to even pull up the SCM view. I'll add, however, that I switched to magit
instead so I have no need for the default VSCode SCM view anymore. magit
is an overall much more comprehensive and less clunky solution so, yeah.
I'm skeptical that most people want to have the focus on their staged items just because they've staged something previously, via "Stage Changes" in the command palette or the like. If they pull up the SCM view via a hotkey it's at least more likely that they'll want to focus the input box. Even so, as I said, I think the explicit command to focus that would be the way to go.
In my case it is for the gitmoji
extension, without being able for the extension to focus the scm, if a user selects a gitmoji and starts typing, the typing happens elsewhere than the source control window which is not ideal...
After a lot of internal discussion, I'm not going to move forward with this proposal and instead ensure the command works for the above scenarios.
Opened https://github.com/microsoft/vscode/issues/131006 to track that
@eamodio makes sense, thanks for your time.
I have an extension that I would like to focus the SCM input box for commit messages.
Today it appears you can only focus the viewlet itself with a command, and the default "git" extension doesn't seem to have ownership of the viewlet, it just has a repository view. This limitation means if someone starts typing after running the command in my extension, they start filtering repositories rather than adding commit message detail.
specifically this method I want to call (I believe): https://github.com/microsoft/vscode/blob/792c23188984484a42007fbf8ea5aa9d43cc5b96/src/vs/workbench/contrib/scm/browser/scmViewPane.ts#L1727-L1736