Skip to content

Commit f0bad89

Browse files
Merge more fixes into july release (#12918)
Co-authored-by: Joyce Er <[email protected]>
1 parent bfa3c82 commit f0bad89

File tree

12 files changed

+35
-45
lines changed

12 files changed

+35
-45
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@
3333
([#12732](https://github.com/Microsoft/vscode-python/issues/12732))
3434
1. Show a prompt asking user to upgrade Code runner to new version to keep using it when in Deprecate PythonPath experiment.
3535
([#12764](https://github.com/Microsoft/vscode-python/issues/12764))
36+
1. Opening notebooks in the preview Notebook editor for [Visual Studio Code Insiders](https://code.visualstudio.com/insiders/).
37+
* Install Python extension in the latest [Visual Studio Code Insiders](https://code.visualstudio.com/insiders/).
38+
* Wait for `Python Extension` to get activated (e.g. open a `Python` file).
39+
* Right click on an `*.ipynb (Jupyter Notebook)` file and select `Open in preview Notebook Editor`.
40+
([#10496](https://github.com/Microsoft/vscode-python/issues/10496))
3641

3742
### Fixes
3843

@@ -119,6 +124,10 @@
119124
([#12656](https://github.com/Microsoft/vscode-python/issues/12656))
120125
1. Add more telemetry for "Select Interpreter" command.
121126
([#12722](https://github.com/Microsoft/vscode-python/issues/12722))
127+
1. Add tests for trusted notebooks.
128+
([#12554](https://github.com/Microsoft/vscode-python/issues/12554))
129+
1. Update categories in `package.json`.
130+
([#12844](https://github.com/Microsoft/vscode-python/issues/12844))
122131

123132
### Thanks
124133

news/1 Enhancements/10496.md

Lines changed: 0 additions & 4 deletions
This file was deleted.

news/3 Code Health/12554.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

news/3 Code Health/12844.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

package.json

Lines changed: 9 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,8 @@
369369
"icon": {
370370
"light": "resources/light/export_to_python.svg",
371371
"dark": "resources/dark/export_to_python.svg"
372-
}
372+
},
373+
"enablement": "notebookViewType == jupyter-notebook && python.datascience.isnotebooktrusted"
373374
},
374375
{
375376
"command": "python.datascience.exportAsPythonScript",
@@ -702,16 +703,7 @@
702703
"light": "resources/light/un-trusted.svg",
703704
"dark": "resources/dark/un-trusted.svg"
704705
},
705-
"enablement": "notebookEditorFocused && !python.datascience.isnotebooktrusted && python.datascience.trustfeatureenabled"
706-
},
707-
{
708-
"command": "python.datascience.notebookeditor.trusted",
709-
"title": "%DataScience.notebookIsTrusted%",
710-
"category": "Python",
711-
"icon": {
712-
"light": "resources/light/trusted.svg",
713-
"dark": "resources/dark/trusted.svg"
714-
}
706+
"enablement": "notebookViewType == jupyter-notebook && !python.datascience.isnotebooktrusted && python.datascience.trustfeatureenabled"
715707
},
716708
{
717709
"command": "python.datascience.notebookeditor.runallcells",
@@ -877,25 +869,19 @@
877869
"command": "python.datascience.notebookeditor.restartkernel",
878870
"title": "%python.command.python.datascience.restartkernel.title%",
879871
"group": "navigation",
880-
"when": "notebookEditorFocused"
872+
"when": "notebookViewType == jupyter-notebook"
881873
},
882874
{
883875
"command": "python.datascience.notebookeditor.trust",
884876
"title": "%DataScience.trustNotebookCommandTitle%",
885877
"group": "navigation@1",
886-
"when": "notebookEditorFocused && !python.datascience.isnotebooktrusted && python.datascience.trustfeatureenabled"
887-
},
888-
{
889-
"command": "python.datascience.notebookeditor.trusted",
890-
"title": "%DataScience.notebookIsTrusted%",
891-
"group": "navigation@1",
892-
"when": "notebookEditorFocused && python.datascience.isnotebooktrusted && python.datascience.trustfeatureenabled"
878+
"when": "notebookViewType == jupyter-notebook && !python.datascience.isnotebooktrusted && python.datascience.trustfeatureenabled"
893879
},
894880
{
895881
"command": "python.datascience.export",
896882
"title": "%DataScience.notebookExportAs%",
897883
"group": "navigation",
898-
"when": "notebookEditorFocused"
884+
"when": "notebookViewType == jupyter-notebook"
899885
}
900886
],
901887
"explorer/context": [
@@ -940,19 +926,19 @@
940926
"command": "python.datascience.exportAsPythonScript",
941927
"title": "%python.command.python.datascience.exportAsPythonScript.title%",
942928
"category": "Python",
943-
"when": "python.datascience.isnativeactive && python.datascience.featureenabled"
929+
"when": "python.datascience.isnativeactive && python.datascience.featureenabled && python.datascience.isnotebooktrusted"
944930
},
945931
{
946932
"command": "python.datascience.exportToHTML",
947933
"title": "%python.command.python.datascience.exportToHTML.title%",
948934
"category": "Python",
949-
"when": "python.datascience.isnativeactive && python.datascience.featureenabled"
935+
"when": "python.datascience.isnativeactive && python.datascience.featureenabled && python.datascience.isnotebooktrusted"
950936
},
951937
{
952938
"command": "python.datascience.exportToPDF",
953939
"title": "%python.command.python.datascience.exportToPDF.title%",
954940
"category": "Python",
955-
"when": "python.datascience.isnativeactive && python.datascience.featureenabled"
941+
"when": "python.datascience.isnativeactive && python.datascience.featureenabled && python.datascience.isnotebooktrusted"
956942
},
957943
{
958944
"command": "python.switchOffInsidersChannel",
@@ -1175,12 +1161,6 @@
11751161
"category": "Python",
11761162
"when": "python.datascience.featureenabled && notebookEditorFocused && !python.datascience.isnotebooktrusted && python.datascience.trustfeatureenabled"
11771163
},
1178-
{
1179-
"command": "python.datascience.notebookeditor.trusted",
1180-
"title": "%DataScience.notebookIsTrusted%",
1181-
"category": "Python",
1182-
"when": "config.noExists"
1183-
},
11841164
{
11851165
"command": "python.datascience.notebookeditor.runallcells",
11861166
"title": "%python.command.python.datascience.notebookeditor.runallcells.title%",

src/client/common/application/commands.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,5 +184,4 @@ export interface ICommandNameArgumentTypeMapping extends ICommandNameWithoutArgu
184184
[DSCommands.GatherQuality]: [string];
185185
[DSCommands.EnableLoadingWidgetsFrom3rdPartySource]: [undefined | never];
186186
[DSCommands.TrustNotebook]: [undefined | never | Uri];
187-
[DSCommands.TrustedNotebook]: [undefined | never];
188187
}

src/client/datascience/constants.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ export namespace Commands {
9191
export const OpenNotebookNonCustomEditor = 'python.datascience.notebookeditor.open';
9292
export const GatherQuality = 'python.datascience.gatherquality';
9393
export const TrustNotebook = 'python.datascience.notebookeditor.trust';
94-
export const TrustedNotebook = 'python.datascience.notebookeditor.trusted';
9594
export const EnableLoadingWidgetsFrom3rdPartySource =
9695
'python.datascience.enableLoadingWidgetScriptsFromThirdPartySource';
9796
}

src/client/datascience/interactive-ipynb/digestStorage.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { inject, injectable } from 'inversify';
33
import * as os from 'os';
44
import * as path from 'path';
55
import { Uri } from 'vscode';
6-
import { traceError } from '../../common/logger';
6+
import { traceError, traceInfo } from '../../common/logger';
77
import { isFileNotFoundError } from '../../common/platform/errors';
88
import { IFileSystem } from '../../common/platform/types';
99
import { IExtensionContext } from '../../common/types';
@@ -13,6 +13,7 @@ import { IDigestStorage } from '../types';
1313
export class DigestStorage implements IDigestStorage {
1414
public readonly key: Promise<string>;
1515
private digestDir: Promise<string>;
16+
private loggedFileLocations = new Set();
1617

1718
constructor(
1819
@inject(IFileSystem) private fs: IFileSystem,
@@ -26,6 +27,10 @@ export class DigestStorage implements IDigestStorage {
2627
const fileLocation = await this.getFileLocation(uri);
2728
// Since the signature is a hex digest, the character 'z' is being used to delimit the start and end of a single digest
2829
await this.fs.appendFile(fileLocation, `z${signature}z\n`);
30+
if (!this.loggedFileLocations.has(fileLocation)) {
31+
traceInfo(`Wrote trust for ${uri.toString()} to ${fileLocation}`);
32+
this.loggedFileLocations.add(fileLocation);
33+
}
2934
}
3035

3136
public async containsDigest(uri: Uri, signature: string) {

src/client/datascience/interactive-ipynb/trustCommandHandler.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import '../../common/extensions';
1313
import { IDisposableRegistry, IExperimentService } from '../../common/types';
1414
import { swallowExceptions } from '../../common/utils/decorators';
1515
import { DataScience } from '../../common/utils/localize';
16-
import { noop } from '../../common/utils/misc';
1716
import { Commands } from '../constants';
1817
import { INotebookStorageProvider } from '../interactive-ipynb/notebookStorageProvider';
1918
import { INotebookEditorProvider, ITrustService } from '../types';
@@ -39,7 +38,6 @@ export class TrustCommandHandler implements IExtensionSingleActivationService {
3938
const context = new ContextKey('python.datascience.trustfeatureenabled', this.commandManager);
4039
context.set(true).ignoreErrors();
4140
this.disposables.push(this.commandManager.registerCommand(Commands.TrustNotebook, this.onTrustNotebook, this));
42-
this.disposables.push(this.commandManager.registerCommand(Commands.TrustedNotebook, noop));
4341
}
4442
@swallowExceptions('Trusting notebook')
4543
private async onTrustNotebook(uri?: Uri) {

src/client/datascience/notebookStorage/notebookModel.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export class NativeEditorNotebookModel extends BaseNotebookModel {
9090

9191
// Dirty state comes from undo. At least VS code will track it that way. However
9292
// skip file changes as we don't forward those to VS code
93-
if (change.kind !== 'save' && change.kind !== 'saveAs') {
93+
if (change.kind !== 'save' && change.kind !== 'saveAs' && change.kind !== 'updateTrust') {
9494
this.changeCount += 1;
9595
}
9696

src/datascience-ui/interactive-common/trustMessage.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ export class TrustMessage extends React.PureComponent<ITrustMessageProps> {
2222
};
2323
const dynamicStyle: React.CSSProperties = {
2424
maxWidth: getMaxWidth(textSize),
25-
color: this.props.isNotebookTrusted ? undefined : 'var(--vscode-editorError-foreground)',
25+
color: this.props.isNotebookTrusted
26+
? 'var(--vscode-editor-foreground)'
27+
: 'var(--vscode-editorError-foreground)',
2628
cursor: this.props.isNotebookTrusted ? undefined : 'pointer'
2729
};
2830

src/datascience-ui/native-editor/addCellLine.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,23 @@ export class AddCellLine extends React.Component<IAddCellLineProps> {
2525
const plus = this.props.includePlus ? (
2626
<Image baseTheme={this.props.baseTheme} class="image-button-image" image={ImageName.InsertBelow} />
2727
) : null;
28+
const disabled = !this.props.isNotebookTrusted;
29+
const innerFilter = disabled ? 'image-button-inner-disabled-filter' : '';
2830
return (
2931
<div className={className}>
3032
<button
3133
role="button"
3234
aria-pressed="false"
3335
title={tooltip}
34-
disabled={!this.props.isNotebookTrusted}
36+
disabled={disabled}
3537
aria-label={tooltip}
3638
className="add-cell-line-button"
3739
onClick={this.props.click}
3840
>
39-
{plus}
40-
<span className="add-cell-line-divider" />
41+
<span className={innerFilter}>
42+
{plus}
43+
<span className="add-cell-line-divider" />
44+
</span>
4145
</button>
4246
</div>
4347
);

0 commit comments

Comments
 (0)