mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Honor removing projects from the Windows jump list
This commit is contained in:
@@ -61,6 +61,19 @@ export class HistoryManager {
|
||||
this.didChangeProjects()
|
||||
}
|
||||
|
||||
removeProject (paths) {
|
||||
if (paths.length === 0) return
|
||||
|
||||
let project = this.getProject(paths)
|
||||
if (!project) return
|
||||
|
||||
let index = this.projects.indexOf(project)
|
||||
this.projects.splice(index, 1)
|
||||
|
||||
this.saveState()
|
||||
this.didChangeProjects()
|
||||
}
|
||||
|
||||
getProject (paths) {
|
||||
for (var i = 0; i < this.projects.length; i++) {
|
||||
if (arrayEquivalent(paths, this.projects[i].paths)) {
|
||||
|
||||
@@ -19,6 +19,8 @@ export default class ReopenProjectMenuManager {
|
||||
}),
|
||||
commands.add('atom-workspace', { 'application:reopen-project': this.reopenProjectCommand.bind(this) })
|
||||
)
|
||||
|
||||
this.applyWindowsJumpListRemovals()
|
||||
}
|
||||
|
||||
reopenProjectCommand (e) {
|
||||
@@ -49,9 +51,30 @@ export default class ReopenProjectMenuManager {
|
||||
this.updateWindowsJumpList()
|
||||
}
|
||||
|
||||
static taskDescription (paths) {
|
||||
return paths.map(path => `${ReopenProjectMenuManager.betterBaseName(path)} (${path})`).join(' ')
|
||||
}
|
||||
|
||||
// Windows users can right-click Atom taskbar and remove project from the jump list.
|
||||
// We have to honor that or the group stops working. As we only get a partial list
|
||||
// each time we remove them from history entirely.
|
||||
applyWindowsJumpListRemovals () {
|
||||
if (process.platform !== 'win32') return
|
||||
if (this.app === undefined) {
|
||||
this.app = require('remote').app
|
||||
}
|
||||
|
||||
const removed = this.app.getJumpListSettings().removedItems.map(i => i.description)
|
||||
if (removed.length === 0) return
|
||||
for (let project of this.historyManager.getProjects()) {
|
||||
if (removed.includes(ReopenProjectMenuManager.taskDescription(project.paths))) {
|
||||
this.historyManager.removeProject(project.paths)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
updateWindowsJumpList () {
|
||||
if (process.platform !== 'win32') return
|
||||
|
||||
if (this.app === undefined) {
|
||||
this.app = require('remote').app
|
||||
}
|
||||
@@ -64,7 +87,7 @@ export default class ReopenProjectMenuManager {
|
||||
({
|
||||
type: 'task',
|
||||
title: project.paths.map(ReopenProjectMenuManager.betterBaseName).join(', '),
|
||||
description: project.paths.map(path => `${ReopenProjectMenuManager.betterBaseName(path)} (${path})`).join(' '),
|
||||
description: ReopenProjectMenuManager.taskDescription(project.paths),
|
||||
program: process.execPath,
|
||||
args: project.paths.map(path => `"${path}"`).join(' '),
|
||||
iconPath: path.join(path.dirname(process.execPath), 'resources', 'cli', 'folder.ico'),
|
||||
|
||||
Reference in New Issue
Block a user