This is closely related to #14745.
I want the selected file in the sidebar to always be my active tab - but do not want the sidebar to scroll just because the file is currently not visible in the sidebar.
That scrolling is the entire reason I turned off autoReveal in the first place.
@clounie so what is missing when you set explorer.autoReveal to false?
You can't tell what file in the tree is currently focused in the editor, or where it is in the tree.
This is because the file highlighted in the sidebar doesn't change unless you manually click to make it so, when autoReveal is false.
@clounie ok I understand your request now, you want to select the file but without scrolling (unless needed).
Yes - if any scrolling is needed, the user should do it.
Agree with @clounie. If explorer.autoReveal is set to false, active files are not highlighted in the explorer anymore. Why not?
Auto-revealing is unwanted because of file tree jumping, not because of highlighting active files.
+1 one from me on this please.
+1
+1, I want the file highlighted in explorer but the scroll position not changed
+1, it's sometimes hard to figure out which file you have open when they're all named index.tsx
I recently switched to VSCode from Atom and I really find this behaviour confusing. autoReveal: false is hardly usable for me if the tree highlights the wrong file, however I'd really like to not have that auto scrolling.
Would be really cool to see this land 👍
+1, really need to improve this behavior. I switched from sublime to vscode, this makes me crazy.
If set autoReveal to true, the jumping inside file explorer is confusing;
If set autoReveal to false, I have to use showActiveFileInExplorer keybinding or right click menu every time when switch between tabs
+1 The editor should not force a scroll by default. It's very distracting.
+1 This is really a needed usability feature.
+1 This is very frustrating. If I have scrolled down in sidebar and then close the tab, it scrolls me back up to the position of the next active tab. Please fix this.
+1 Been a couple of years for a simple option to prevent a part of an existing feature; should be simple enough to implement?
EDIT: Looks like the operation is happening here:
https://github.com/microsoft/vscode/blob/0593e5b600cca44c09f193769b2420f260691a85/src/vs/workbench/contrib/files/browser/views/explorerView.ts#L684
One option is to add another settings option, such as autoRevealNoScroll, and add it to the existing check:
const autoRevealNoScroll= this.configurationService.getValue<IFilesConfiguration>().explorer.autoRevealNoScroll;
if (!autoRevealNoScroll || this.tree.getRelativeTop(item) === null) {
The relevant tree function seem to be in:
https://github.com/microsoft/vscode/blob/8350cebf42e2d76a8a6d07d4f94bfa082d5f99c3/src/vs/base/browser/ui/tree/abstractTree.ts#L1206
I see that there's some debate in the PR so I just wanted to add a +1 in support of this fix.
I actually keep unneeded files open sometimes, if I know I'm going to be touching an adjacent file next, just so that I can make sure I don't have to scroll back in the project to where I was.
Thank you @phuein for putting the fix together! A nice potential additional feature would be the ability to do something like right-click a file's tab, and have an option in the context menu to update the left scrollbar's position to that file. Then, on the rare occasion that I do care if the two are in sync, it would be just a couple of clicks away.
Actually the feature above is already there! "Reveal in Side Bar." So never mind. I'll leave the above text here in case it helps anyone else once this PR goes live.
Thanks to @phuein this is now supported in VS Code.
To verify:
explorer.autoReveal: true | false behave as beforeexplorer.autoReveal: focusNoScroll focuses the active editor but does not scroll the explorerAwesome to see this merged! The new option is called highlightNoScroll though, right?
I renamed it to focusNoScroll via a06c753e0b
Ah, got it – thanks! 🙂
Most helpful comment
Thanks to @phuein this is now supported in VS Code.
To verify:
explorer.autoReveal: true | falsebehave as beforeexplorer.autoReveal: focusNoScrollfocuses the active editor but does not scroll the explorer