Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add copy file path action to Tracked Explorer Tree #570

Merged
merged 4 commits into from
Jun 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,11 @@
"command": "dvc.removeTarget",
"category": "DVC",
"icon": "$(trash)"
},
{
"title": "%command.copyFilePath%",
"command": "dvc.copyFilePath",
"category": "DVC"
}
],
"configuration": {
Expand Down Expand Up @@ -311,6 +316,10 @@
{
"command": "dvc.removeTarget",
"when": "false"
},
{
"command": "dvc.copyFilePath",
"when": "false"
}
],
"scm/title": [
Expand Down Expand Up @@ -420,6 +429,10 @@
"command": "dvc.pullTarget",
"group": "DVC",
"when": "viewItem != dvc"
},
{
"command": "dvc.copyFilePath",
"group": "1_cutcopypaste"
}
]
},
Expand Down
1 change: 1 addition & 0 deletions extension/package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"command.addTarget": "Add Target",
"command.checkout": "Checkout",
"command.checkoutTarget": "Checkout Target",
"command.copyFilePath": "Copy Path",
"command.commit": "Commit",
"command.commitTarget": "Commit Target",
"command.deleteTarget": "Delete",
Expand Down
3 changes: 3 additions & 0 deletions extension/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import { definedAndNonEmpty } from './util/array'
import { setContextValue } from './vscode/context'
import { OutputChannel } from './vscode/outputChannel'
import { WebviewSerializer } from './webviewSerializer'
import { reRegisterVsCodeCommands } from './vscode/commands'

export { Disposable, Disposer }

Expand Down Expand Up @@ -147,6 +148,8 @@ export class Extension implements IExtension {
registerRepositoryCommands(this.cliExecutor)

this.registerConfigCommands()

reRegisterVsCodeCommands(this.dispose)
}

public hasRoots = () => definedAndNonEmpty(this.dvcRoots)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@ suite('Extension Test Suite', () => {
})

describe('TrackedExplorerTree', () => {
it('should be able to run dvc.copyFilePath and copy a path to the clipboard', async () => {
await commands.executeCommand('dvc.copyFilePath', dvcDemoPath)

await commands.executeCommand('workbench.action.files.newUntitledFile')
await commands.executeCommand('editor.action.clipboardPasteAction')

expect(window.activeTextEditor?.document.getText()).to.equal(dvcDemoPath)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#570 (comment) and 40 minutes later we have this.... 🤯

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is wild

})

it('should be able to run dvc.deleteTarget without error', async () => {
const path = join(dvcDemoPath, 'deletable.txt')
ensureFileSync(path)
Expand Down
10 changes: 10 additions & 0 deletions extension/src/vscode/commands.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Disposer } from '@hediet/std/disposable'
import { commands, Uri } from 'vscode'

export const reRegisterVsCodeCommands = (disposer: Disposer) => {
disposer.track(
commands.registerCommand('dvc.copyFilePath', path =>
commands.executeCommand('copyFilePath', Uri.file(path))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[F] I tried to simply reference this in our package json and it could not be found so looks like we need to wrap it.

)
)
}