Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is 'Restricted mode' in the VS Code status bar and how can I disable it?

In VS Code 1.57, I see this on the left of my status bar:

enter image description here

What is Restricted mode and how I can I remove this from my status bar?

like image 391
Matt Bierner Avatar asked Jun 10 '21 04:06

Matt Bierner


People also ask

Why is my VS Code in restricted mode?

You will also see a Restricted Mode badge in the Status bar. Restricted Mode tries to prevent automatic code execution by disabling or limiting the operation of several VS Code features: tasks, debugging, workspace settings, and extensions.

What is the code to disable code in Visual Studio?

Go to File > Preferences > Settings. Under drop-down Text Editor , search for Code Lens and disable it.

How do I turn on VS Code bar status?

Search for “status bar” and check/uncheck the checkbox in the “Workbench > Status Bar: Visible” section to show/hide the status bar, respectively.

How do I enable edit mode in VS Code?

You can invoke these from the Command Palette (Ctrl+Shift+P) or the editor context menu. VS Code has default formatters for JavaScript, TypeScript, JSON, and HTML.


2 Answers

How to disable the "Trust" feature

This will disable all prompts and trust mode features, making vscode behave exactly like it did before this feature was added.

  • GUI (ctrl ,)

    • Search for "Trust" in the settings menu and uncheck: security.workspace.trust.enabled
  • settings.json

    • add the following line: "security.workspace.trust.enabled": false

enter image description here

like image 152
Brennen Sprimont Avatar answered Oct 06 '22 00:10

Brennen Sprimont


What is Restricted Mode?

At first glance, this new "Restricted Mode" seems unnecessary and obtrusive.

I believe its purpose is to prevent execution of untrusted code - e.g. as a result of an extension or using the "debug" option on an untrusted file. It seems to work in a similar manner to the restricted mode on MS Office apps, like MS Word, which restricts editing, saving and printing files until manually enabled.

From the Visual Studio Code documentation on Workspace Trust:

Restricted Mode tries to prevent automatic code execution by disabling or limiting the operation of several VS Code features: tasks, debugging, workspace settings, and extensions.

Personally, I have never come up against a situation where this would have been a problem and it seems like a constant nuisance for the sake of the one occasion it could be useful. That said, I imagine some people work with potentially dodgy files more often.

What can I do about it?

There are four new settings that allow us to customise this feature: Security Settings in VS Code 1.57

If you wanted to remove the feature, you can just switch off Trust, which "Controls whether or not workspace trust is enabled within VS Code". I have tried this and it does seem to completely disable this new feature - even removing related options from the command palette.

You can also control how VS Code works when opening an empty environment and how VS Code behaves with regards to untrusted files.

If you keep "Trust" enabled, you can also configure folders that you consider "safe" - for example your usual workspace, vs. your downloads folder.

Follow these steps to configure your trusted folders:

  1. Hit CTRL+SHIFT+P (or your local equivalent) to open the Command Palette.
  2. Start typing Workspaces: Manage Workspace Trust and select the entry when it comes up.
  3. Alternatively, click the cog and select "Manage Workplace Trust", as it seems there is a new entry for it there.
  4. You will be presented with the following form, showing the option to trust/untrust the current window and an option at the bottom-left to configure trusted folders:

Manage Workspace Trust

  1. Select the "Add Folder" button at the bottom and add folders that you trust.

Where can I find more information?

The release notes for VS Code v1.57 can be found on GitHub. There is also a specific page dedicated to workspace trust on code.visualstudio.com.

like image 21
m-smith Avatar answered Oct 05 '22 23:10

m-smith