How do I stop VSCode from revealing a file in the sidebar as soon as I click on it in "Source Control => Changes" - visual-studio-code

When I have a multiple file with changes in VSCode I often want to go trough the changes without staging.
I cannot do this because as soon as I click on one file with changes in "Source Control => Changes" the file is revealed in the sidebar and I have to navigate back to "Source Control" to review the changes of another file. In the past this wasn't the case. In order to open the file regularly (without diff) I could manually go to the Explorer and the file was selected.
When files are staged I can click on them and they will not be revealed in the sidebar. This behavior is what I would also like to have for files that are not staged.
What is causing this behavior (I use VSCode v1.74.2)? In the past this wasn't the case.
Update: This behavior is caused by an extension I need (Sigasi). They made an update and for some reason this caused the described unwanted behavior.

Hello from the Sigasi support department. ;)
The Sigasi extension for VS Code comes with a dedicated Project View to bring some useful Eclipse File System features to our VS Code extension.
One of the features this Project View offers, is to link the Project View with the editor in focus. This allows to quickly spot where you are in the project file hierarchy.
This feature can easily be disabled by going to the Project View and clicking the icon that controls the link with the editor. I'm linking a screenshot showing the link with editor setting.
It seems this feature at the moment is more intrusive than intended. We plan to adjust this feature so that it isn't active if the Project View is not visible or collapsed.

Related

How do I restore the stashes menu in Visual Studio Codes Source Control panel?

I can't find the Stashes (nor REMOTES, BRANCHES, FILE HISTORY) menu in the Source Control (the one you open up with Ctrl-Shift-U) tool bar.
This is how my Visual Studio Code looks like:
And this is a picture I found on the web with the menu options I'd like to restore:
I couldn't find an option to restore these menu options.
it seems like somehow GitLens, instead of replacing the Source Control panel, add his own:
You need to install (or enable if you have it disabled) the GitLens extension. That is what adds those sub-sections seen in your second screenshot.
Alternatively, if you click the ellipsis that is to the right of each of your repositories, you should see a "Stash" menu item that should also meet most of your needs.
Note that the GitLens extension is apart of the Git Extension Pack extension, which contains a few other extensions as well (including Git History, which you appear to have already).
Just for reference, in case anybody else stumbles upon this issue.
I created this issue at GitLens github repo and the solution was to right click on the original 'Source Control' icon and select the option "Reset location"
It seems it's not the first time that something like this happened.

What is that component on the top-right of VS Code called? How can I change the setting of it?

I'm using VS Code on Mac and I was curious about one component.
Every time I open a new python file, this component will show up on the top right of the current window? But I can't find the name of it.
That's not just "one component", but actually multiple buttons added to the editor actions toolbar from multiple extensions installed on your VS Code.
In order from left to right:
Open Changes (built-in with VS Code as part of their Version Control functions)
Run Python File in Terminal (added by Microsoft's own Python extension)
Open Changes in previous revision (added by the GitLens extension)
Show Revision Details (added by the GitLens extension)
Open Changes in next revision (added by the GitLens extension)
Toggle File Blame Annotations (added by the GitLens extension)
Split Editor (built-in with VS Code)
For GitLens, they are automatically added when it detects the currently opened file is part of a git repository. You can configure them by accessing the command palette (CMD+Shift+P on a Mac), then entering "GitLens: Open Settings". Find the "Menus & Toolbars" section:
For example, if you want to remove buttons 3., 4., and 5., uncheck "Add commands to the editor group toolbar" > "Add comparison commands". Then reload VS Code. You can configure all the other settings there.
For the green Play button, it automatically appears when you the currently active file is a Python file. AFAIK, there is no way to configure or hide/remove it other than disabling the Python extension completely (which you certainly don't want to do). There are requests on VS Code's Github page to hide it, like this: Add setting to disable icon for "Run Python File In Terminal".
For the "Open Changes" and "Split Editor" buttons, AFAIK there is no built-in way to hide/remove them. You can only control the behavior from the VS Code settings:
As mentioned in the comments, there is a feature request for VS Code to Allow hiding the buttons in the tab bar line and in the panel title bar, which includes the "Open Changes" and "Split Editor" buttons. There are users who provided workarounds at hiding the buttons using extensions. You may want to follow that thread and/or try out some of those extensions.

How to open files in new tabs in Visual Studio Code

I recently started using Visual Studio Code and I would like to know, is a way to open files in a new tab? Currently whenever I open a new file the files I currently have open disappear. I say new tab, but any option that will let me open a new file in the same window as the old one works.
I have tried disabling Preview Mode through the workbench settings as shown in this answer: How to config vscode to open files always in a new tab?. However, when I choose Open or Open Recent the new file still replaces my old file.
Thanks.
Once you have to open your settings file, add the "workbench.editor.enablePreview" property and set value to false.
For 1.21.1 version.
In user settings =>
"workbench.editor.enablePreview": false,
"workbench.editor.enablePreviewFromQuickOpen"
the best way i found.
Starting with VSCode 1.52 (Nov. 2020), you should not have any more issue: all files will open in new tabs, even in preview mode.
Better handling of preview editors:
Preview editors are now better handled with numerous improvements based on feedback and making this feature work more consistent.
The setting workbench.editor.enablePreviewFromQuickOpen is now disabled by default so that editors opening from quick open will not appear in preview mode anymore.
When you start a navigation (e.g. go to definition), the editor you start from will move out of preview mode to keep it open while the new editor will be in preview mode until you navigate further.
We changed all of our custom trees (the ones used from extensions or Git changes view for example) to work more consistently like our built-in trees (like the explorer).
This means, the following interactions now apply to all of them:
double-click or mouse-middle-click to open non-preview
Enter to open non-preview (Space to open in preview-mode)
Note: if you are the author of an extension that is leveraging our custom tree API, you can benefit from this change as well.
Make sure to use vscode.open or vscode.diff commands for the TreeItem.command and you are in!
A new menu item in the editor overflow menu allows to quickly turn off preview editors altogether:
You need to double click on the name of the file. Also, it needs to be done swiftly elsewhere you will be opening in the same tab.
You can drag and drop file near to the opened tab and the file will open in new tab.
Thanks everyone. Double clicking and dragging was useful, but it still didn't solve my problem when opening files from different projects with the "Open File" menu command. I found that Multi-root Workspaces is what I was looking for. https://code.visualstudio.com/docs/editor/multi-root-workspaces
This is likely due to Visual Studio Code opening file in what's called "Preview Mode", which allows you to quickly view files, ideally if a tab is in Preview Mode then its title in the tab bar, will be italic.
To disable Preview Mode set "workbench.editor.enablePreview": false in your settings file or use the "workbench.editor.enablePreviewFromQuickOpen" option to disable it only from the quick open menu.
Alternatively, use command palette CTL+Shift+P (to get all settings) VScode settings then in User => Workbench => Editor Management you can uncheck Enable Preview and Enable Preview from Quick Open to get the same results described above

VSCode: How to turn off auto select in File Explorer when changing window tabs?

In VSCode, if I have an editor window tab open and I click anywhere in that editor window, the selected file in the File Explorer changes to the file being edited. I would like to prevent that behavior. This is possible in Visual Studio, but I can't seem to find a similar setting in the preferences file of VSCode.
Can anyone provide some suggestions?
This has been added, see https://github.com/Microsoft/vscode/issues/14745.
Configuration is "explorer.autoReveal": false
You can't, at least not today. The only thing you can do, is keeping the scroll position when switching tabs. See this answer for the setting: VSCode prevent file Explorer from jumping
And here is the feature request on Github: https://github.com/Microsoft/vscode/issues/14745
(Feel free to add a "Thumbs Up" via Github Reaction at the top so the request gets more attention in the future, this increases the chances that it gets implemented sooner)

How do I stop VSCode from the Side Bar moving to the folder that the current file is in?

In Visual Studio Code, whenever I close a file, the next open file becomes active in the editor and the Side Bar moves to that file's location in the folder structure. This is usually not the behavior I want. I often want to open another file in the same location as the one I just closed, but now my Side Bar has shifted around to what could be a totally different place in a large project.
I like the behavior of the main Visual Studio product where the Solution does not automatically shift. Instead, if I want to see where in the solution a file is, I can use a keyboard shortcut to move there ("Find File in Solution"), instead of automatically moving there every time the active file changes.
Is there any way to change/disable this functionality in VSCode?
The is an option explorer.autoReveal in settings (either user or workspace) which controls if the explorer should automatically reveal files when opening them.
Open VS User Settings (Preferences > User Settings). This will open two side-by-side documents.
Add a new "explorer.autoReveal": false setting to the User Settings document on the right if it's not already there. This is so you aren't editing the Default Setting directly, but instead adding to it.
Save the User Settings file.
in Version: 1.42.1
Open VS User Settings (Preferences > User Settings).
Search for "explorer auto reveal" without quotes.
Now uncheck the checkbox.
There is a new setting in v1.46 that will select the files in the explorer but not scroll to reveal them:
We have introduced a new value focusNoScroll to the
explorer.autoReveal setting. For this value Explorer will
automatically select files when opening them but will not reveal them.
from v1.46 release notes.
So that setting will highlight the active editor in the explorer but not scroll to it.