-
Notifications
You must be signed in to change notification settings - Fork 294
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
Fix export to use the source file for the directory it wants to open #4072
Conversation
export const PythonExtensions = { Python: ['py'] }; | ||
|
||
@injectable() | ||
export class ExportDialog implements IExportDialog { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file used to be called ExportManagerFilePicker. I thought this name made more sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bleh, github didn't pick up the rename though? Can't easily tell what changed...
} finally { | ||
this.stopProgress(); | ||
// Pull out the metadata from our active notebook | ||
const metadata: nbformat.INotebookMetadata = { orig_nbformat: 3 }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This wasn't working before. Now the exported notebook will have the actual kernel inside of it.
@@ -96,5 +96,5 @@ export async function computeWorkingDirectory(resource: Resource, workspace: IWo | |||
} | |||
|
|||
// Otherwise a file without an extension or directory doesn't exist. Just use the workspace root | |||
return workspace.getWorkspaceFolder(resource)?.uri.fsPath || process.cwd(); | |||
return workspace.getWorkspaceFolder(resource)?.uri.fsPath || workspace.rootPath || process.cwd(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems getWorkspaceFolder only works if you're in a workspace.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI - Under the hood workspace.rootPath
also uses workspace.worksapceFolders
, hence if you don't have a workspace folder opened, then workspace.root
will still return undefined
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No change required.
exportMethod?: ExportFormat, | ||
defaultFileName?: string, | ||
interpreter?: PythonEnvironment | ||
) { | ||
if (!model) { | ||
// if no model was passed then this was called from the command palette, | ||
if (!contents || !source) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you check calling this Export command from the command palette with all our types of editor? I thought when I was looking at this recently there was a case where a Model was getting passed in. I think that it might have been Old editor active editor = Command is called with all undefined. CustomEditor active editor = Command is called with an INotebookModel. Not 100% sure I'm recalling correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes this should work (I'll double check). This happens when you try to export a notebook from the command palette (instead of from our toolbar).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good thing I double checked. Found another issue. Interactive window would show the export commands if a notebook had ever been opened. Since the active editor here is from the notebook, the export command would essentially do nothing.
The bug was in our tracking of active editor. We weren't firing the change of the active editor on close.
Like the new changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems good with just that one thing to check.
…e much harder to support)
For #3991
Rework how export is done to not have to use INotebookModel anymore. This allows the decoupling of the model from the file it has (necessary for the interactive window to export correctly).
Then change all exporting paths to go through the same 'IExportDialog' class which will use the source file to pick the directory to export to.
package-lock.json
has been regenerated by runningnpm install
(if dependencies have changed).