Skip to content

Commit 4e8cba5

Browse files
committed
Fix context menus to not run cell commands twice (#4544)
* Fix issue with id not being passed in on context menus * Add news entry
1 parent e7015a8 commit 4e8cba5

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

news/2 Fixes/4532.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix double running of cells with the context menu

src/client/datascience/editor-integration/codewatcher.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Licensed under the MIT License.
33
'use strict';
44
import { inject, injectable } from 'inversify';
5+
import * as uuid from 'uuid/v4';
56
import { CodeLens, Command, Position, Range, Selection, TextDocument, TextEditor, TextEditorRevealType } from 'vscode';
67

78
import { IApplicationShell, IDocumentManager } from '../../common/application/types';
@@ -87,7 +88,7 @@ export class CodeWatcher implements ICodeWatcher {
8788
const range: Range = new Range(lens.command.arguments[1], lens.command.arguments[2], lens.command.arguments[3], lens.command.arguments[4]);
8889
if (this.document && range) {
8990
const code = this.document.getText(range);
90-
await activeHistory.addCode(code, this.getFileName(), range.start.line, id);
91+
await activeHistory.addCode(code, this.getFileName(), range.start.line, uuid());
9192
}
9293
}
9394
}
@@ -96,7 +97,7 @@ export class CodeWatcher implements ICodeWatcher {
9697
if (this.codeLenses.length === 0) {
9798
if (this.document) {
9899
const code = this.document.getText();
99-
await activeHistory.addCode(code, this.getFileName(), 0, id);
100+
await activeHistory.addCode(code, this.getFileName(), 0, uuid());
100101
}
101102
}
102103
}
@@ -119,7 +120,7 @@ export class CodeWatcher implements ICodeWatcher {
119120
}
120121

121122
if (code && code.trim().length) {
122-
await activeHistory.addCode(code, this.getFileName(), activeEditor.selection.start.line, id, activeEditor);
123+
await activeHistory.addCode(code, this.getFileName(), activeEditor.selection.start.line, uuid(), activeEditor);
123124
}
124125
}
125126
}
@@ -132,7 +133,7 @@ export class CodeWatcher implements ICodeWatcher {
132133
const code = this.document.getText(range);
133134

134135
try {
135-
await activeHistory.addCode(code, this.getFileName(), range.start.line, id, this.documentManager.activeTextEditor);
136+
await activeHistory.addCode(code, this.getFileName(), range.start.line, uuid(), this.documentManager.activeTextEditor);
136137
} catch (err) {
137138
this.handleError(err);
138139
}

0 commit comments

Comments
 (0)