I rely heavily on the File: Open Recent…
command to open frequently used files, but yesterday my local Google Drive folder got moved to a new location and now I can no longer access any of the files in that folder through the Open Recent panel because the paths don't match.
The fix would be as simple as replacing "/Google Drive/" with "/Google Drive/My Drive/" but I have no idea what file contains the list of files that appears in the recently opened panel.
I'm assuming it's somewhere in ~/Library/Application Support/Code
but not sure where.
I was wondering the same thing the other day and found this while searching for a solution, so I took some time to investigate it today.
It's been a a few weeks since you posted, so hopefully this will still be of help to you.
Location of settings
Those setting are stored in the following files:
%APPDATA%\Code\User\globalStorage\state.vscdb
~/Library/Application Support/Code/User/globalStorage/state.vscdb
~/.config/Code/User/globalStorage/state.vscdb
If your software is cross-platform, you may want to consider using a library such as Python's platformdirs to determine the path.
The file is an sqlite3 database, which is used as a key-value store.
It has a single table named ItemTable
and the relevant key is history.recentlyOpenedPathsList
.
The value has the following structure:
{
"entries": [
{
// Only one of these two will be present, depending on whether
// the history entry is a folder or file
"folderUri": "path:///path/to/folder",
"fileUri": "path:///path/to/file",
// These properties may not exist on all entries
"label": "...",
"remoteAuthority": "..."
}
]
}
To view the current list, you can run the following command:
sqlite3 -readonly "$VSCODE_STATE_PATH" "SELECT [value] FROM ItemTable WHERE [key] = 'history.recentlyOpenedPathsList'" | jq
Modifying the settings
Specifically, I was interested in changing the way it's displayed (the label), so I'll detail how I did that, but it should be just as easy to update the path.
Here's the Python code I used to make those edits:
import json, sqlite3, platformdirs
from typing import TypedDict, NotRequired
class VsCodeHistoryEntry(TypedDict):
folderUri: NotRequired[str]
fileUri: NotRequired[str]
label: NotRequired[str]
remoteAuthority: NotRequired[str]
vscode_state_path = (
platformdirs.user_config_path()
/ "Code/User/globalStorage/state.vscdb"
)
# Open the db, get the value and parse it
db = sqlite3.connect(vscode_state_path)
history_raw = db.execute("SELECT [value] FROM ItemTable WHERE [key] = 'history.recentlyOpenedPathsList'").fetchone()[0]
history: list[VsCodeHistoryEntry] = json.loads(history_raw)["entries"]
# Make the changes you'd like
# ...
# Stringify and update
history_raw = json.dumps({"entries": history})
# ? used as placeholder to avoid accidental SQL injection
db.execute(
"UPDATE ItemTable SET [value] = ? WHERE key = 'history.recentlyOpenedPathsList'",
(history_raw,),
)
db.commit()
db.close()
Code references
For reference (mostly for my future self), here are the relevant source code areas:
File->Open Recent
uses those values as-is (see here).Get Started
page, the Recents
area is populated here. In the Get Started
, the label is presented in a slightly different way:Notes
Links