Esempio n. 1
0
        public async Task <CommandResult> InvokeAsync()
        {
            string filePath = GetFilePath();

            if (filePath == null)
            {
                return(CommandResult.NotSupported);
            }

            var textView     = GetActiveTextView();
            var activeWindow = _interactiveWorkflow.ActiveWindow;

            if (textView == null || activeWindow == null)
            {
                return(CommandResult.NotSupported);
            }

            _interactiveWorkflow.Shell.SaveFileIfDirty(filePath);
            activeWindow.Container.Show(focus: false, immediate: false);

            var session = _interactiveWorkflow.RSession;

            if (session.IsRemote)
            {
                using (DataTransferSession dts = new DataTransferSession(_interactiveWorkflow.RSession, new FileSystem())) {
                    // TODO: add progress indication and cancellation
                    string remotePath = await dts.CopyFileToRemoteTempAsync(filePath, true, null, CancellationToken.None);

                    await _interactiveWorkflow.Operations.SourceFileAsync(remotePath, _echo, textView.TextBuffer.GetEncoding());
                }
            }
            else
            {
                await _interactiveWorkflow.Operations.SourceFileAsync(filePath, _echo, textView.TextBuffer.GetEncoding());
            }
            return(CommandResult.Executed);
        }