Skip to content

Commit

Permalink
feat(vscode): 适配 vscode 1.64.0+
Browse files Browse the repository at this point in the history
  • Loading branch information
simonwong committed Feb 7, 2022
1 parent 612400d commit 2eb4734
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 13 deletions.
25 changes: 13 additions & 12 deletions vscode/index.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
const alfy = require('alfy');
const homedir = require('os').homedir
const readFileSync = require('fs').readFileSync
import alfy from 'alfy'
import os from 'os'
import fs from 'fs'

const homedir = os.homedir
const readFileSync = fs.readFileSync
const STORAGE_PATH = `${homedir()}/Library/Application\ Support/Code/storage.json`

const vscStorage = JSON.parse(readFileSync(STORAGE_PATH).toString())
const { openedPathsList } = vscStorage

const fileItems = vscStorage.lastKnownMenubarData.menus.File.items

const recentList = fileItems.find(item => item.id.startsWith('submenuitem') && item.submenu)?.submenu.items

let files = []

openedPathsList.entries.forEach(item => {
if (item.folderUri) {
files.push(item.folderUri)
} else if (item.workspace) {
files.push(item.workspace.configPath)
recentList.forEach(item => {
if (['openRecentWorkspace', 'openRecentFile'].includes(item.id)) {
files.push(item.uri.path)
}
})

const data = [...new Set(files)].map(file => {
if (typeof file === 'object' && 'configURIPath' in file) {
file = file.configURIPath
}
file = decodeURI(file.replace(/^file:\/\//, ''))
const fileSplit = file.split('/')

Expand Down
3 changes: 2 additions & 1 deletion vscode/run.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const { exec } = require('child_process')
import { exec } from 'child_process'

const filePath = process.argv.slice(-1)[0]

exec(`code ${filePath}`, (error, stdout) => {
Expand Down
Binary file removed vscode/vscode-v0.0.2.alfredworkflow
Binary file not shown.
Binary file added vscode/vscode-v0.0.3.alfredworkflow
Binary file not shown.

0 comments on commit 2eb4734

Please sign in to comment.