open in vscode

pull/5370/head
filip mertens 1 year ago
parent 13a14d48e1
commit 5d18230bf2
  1. 5
      apps/remix-ide/src/app/components/preload.tsx
  2. 5
      apps/remix-ide/src/app/files/electronProvider.ts
  3. 2
      apps/remix-ide/src/app/files/fileManager.ts
  4. 6
      apps/remix-ide/src/app/panels/file-panel.js
  5. 11
      apps/remix-ide/src/remixAppManager.js
  6. 6
      apps/remixdesktop/src/plugins/fsPlugin.ts
  7. 1
      libs/remix-ui/app/src/lib/remix-app/remix-app.tsx

@ -29,15 +29,10 @@ export const Preload = () => {
)
function loadAppComponent() {
// log time
console.log('app import', new Date().toLocaleString())
import('../../app')
.then((AppComponent) => {
console.log('app loaded', new Date().toLocaleString())
const appComponent = new AppComponent.default()
console.log('app run', new Date().toLocaleString())
appComponent.run().then(() => {
console.log('Remix loaded', new Date().toLocaleString())
render(
<>
<RemixApp app={appComponent} />

@ -17,7 +17,6 @@ export class ElectronProvider extends FileProvider {
async init() {
this._appManager.on('fs', 'change', async (event, path) => {
console.log('change', event, path)
switch (event) {
case 'add':
this.event.emit('fileAdded', path)
@ -45,8 +44,6 @@ export class ElectronProvider extends FileProvider {
// isDirectory is already included
// this is a more efficient version of the default implementation
async resolveDirectory(path, cb) {
console.log('resolveDirectory', path)
console.log('start', new Date(new Date().getTime()).toLocaleTimeString())
path = this.removePrefix(path)
if (path.indexOf('/') !== 0) path = '/' + path
try {
@ -61,8 +58,6 @@ export class ElectronProvider extends FileProvider {
// ^ ret does not accept path starting with '/'
}
}
//console.log(ret, 'ret resolveDirectory ELECTRON')
console.log('end', new Date(new Date().getTime()).toLocaleTimeString())
if (cb) cb(null, ret)
return ret
} catch (error) {

@ -476,7 +476,7 @@ class FileManager extends Plugin {
})
})
} catch (e) {
throw new Error(e)
return {}
}
}

@ -100,10 +100,8 @@ module.exports = class Filepanel extends ViewPlugin {
*/
registerContextMenuItem(item) {
return new Promise((resolve, reject) => {
this.emit('registerContextMenuItemReducerEvent', item, (err, data) => {
if (err) reject(err)
else resolve(data)
})
this.emit('registerContextMenuItemReducerEvent', item)
resolve(item)
})
}

@ -339,6 +339,17 @@ export class RemixAppManager extends PluginManager {
sticky: true,
group: 8
})
await this.call('filePanel', 'registerContextMenuItem', {
id: 'fs',
name: 'openInVSCode',
label: 'Open in VSCode',
type: ['folder', 'file'],
extension: [],
path: [],
pattern: [],
sticky: true,
group: 8
})
}
}
}

@ -86,7 +86,7 @@ const clientProfile: Profile = {
name: 'fs',
displayName: 'fs',
description: 'fs',
methods: ['readdir', 'readFile', 'writeFile', 'mkdir', 'rmdir', 'unlink', 'rename', 'stat', 'lstat', 'exists', 'currentPath', 'watch', 'closeWatch', 'setWorkingDir', 'openFolder', 'openFolderInSameWindow', 'getRecentFolders', 'removeRecentFolder', 'openWindow', 'selectFolder', 'revealInExplorer', 'openInVSCode']
methods: ['readdir', 'readFile', 'writeFile', 'mkdir', 'rmdir', 'unlink', 'rename', 'stat', 'lstat', 'exists', 'currentPath', 'watch', 'closeWatch', 'setWorkingDir', 'openFolder', 'openFolderInSameWindow', 'getRecentFolders', 'removeRecentFolder', 'openWindow', 'selectFolder', 'revealInExplorer', 'openInVSCode', 'openInVSCode']
}
class FSPluginClient extends ElectronBasePluginClient {
@ -333,6 +333,10 @@ class FSPluginClient extends ElectronBasePluginClient {
shell.showItemInFolder(this.fixPath(action.path[0]))
}
async openInVSCode(action: customAction): Promise<void> {
shell.openExternal(`vscode://file/${this.fixPath(action.path[0])}`)
}
fixPath(path: string): string {
if (this.workingDir === '') throw new Error('workingDir is not set')
if (path) {

@ -46,7 +46,6 @@ const RemixApp = (props: IRemixAppUi) => {
setLocale(props.app.localeModule.currentLocale())
}
if (props.app) {
console.log('app activate', new Date().toLocaleString())
activateApp()
}
const hadUsageTypeAsked = localStorage.getItem('hadUsageTypeAsked')

Loading…
Cancel
Save