Skip to content

Commit

Permalink
Fix Recent list in dock does not show recent files/folders microsoft#…
Browse files Browse the repository at this point in the history
…74788

macOS only shows recent list with max number based on sytem config. It takes bottom n entries from the list added through Electron app.addRecentDocument. To match macOS dock recent list with VSCode internal recent list, this change add items into macOS recent document list in reverse order of internal recent list.
  • Loading branch information
malingyan2017 committed Jun 8, 2019
1 parent a848f18 commit ee1e87b
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions src/vs/platform/history/electron-main/historyMainService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,20 +147,12 @@ export class HistoryMainService implements IHistoryMainService {

const mru = this.getRecentlyOpened();

// Fill in workspaces
for (let i = 0, entries = 0; i < mru.workspaces.length && entries < HistoryMainService.MAX_MACOS_DOCK_RECENT_FOLDERS; i++) {
const loc = location(mru.workspaces[i]);
if (loc.scheme === Schemas.file) {
const workspacePath = originalFSPath(loc);
if (await exists(workspacePath)) {
app.addRecentDocument(workspacePath);
entries++;
}
}
}
// macOS only shows last n items of recent document list if it has more than the config
// of System Preferences/General/Recent items. To match VSCode Recent workspace/file list,
// add files first, then workspaces, and add in reverse order.

// Fill in files
for (let i = 0, entries = 0; i < mru.files.length && entries < HistoryMainService.MAX_MACOS_DOCK_RECENT_FILES; i++) {
for (let i = mru.files.length - 1, entries = 0; i >= 0 && entries < HistoryMainService.MAX_MACOS_DOCK_RECENT_FILES; i--) {
const loc = location(mru.files[i]);
if (loc.scheme === Schemas.file && HistoryMainService.COMMON_FILES_FILTER.indexOf(basename(loc)) === -1) {
const filePath = originalFSPath(loc);
Expand All @@ -170,6 +162,18 @@ export class HistoryMainService implements IHistoryMainService {
}
}
}

// Fill in workspaces
for (let i = mru.workspaces.length - 1, entries = 0; i >= 0 && entries < HistoryMainService.MAX_MACOS_DOCK_RECENT_FOLDERS; i--) {
const loc = location(mru.workspaces[i]);
if (loc.scheme === Schemas.file) {
const workspacePath = originalFSPath(loc);
if (await exists(workspacePath)) {
app.addRecentDocument(workspacePath);
entries++;
}
}
}
}

clearRecentlyOpened(): void {
Expand Down

0 comments on commit ee1e87b

Please sign in to comment.