Commit 689c28e
Fix copy/paste in notebooks (#11024)
Addresses #10240
This PR addresses the issue where copying a cell (`C`) and pasting it
inside another cell's editor (`Cmd+V`) would paste the cell metadata
instead of the cell contents.
Additionally, this PR addres support for cross-notebook copy/paste.
Cells can now be copy/pasted between different notebooks which was not
previously supported.
--
Positron notebooks has specific code to handle copy/pasting cell objects
into notebooks. The system clipboard is used to handle pasting into
editors (including cell editors).
When users copied a cell (`C` key or "Copy cell" button), we were
writing the cell json to the notebook clipboard and the system
clipboard. This is why when a users copied a cell (`C` key or "Copy
cell" button) and then pasted inside a cell editor (edit mode), they
would get json instead of the text in the cell.
A code cell with the contents: `print("Hello World")` would return the
following:
```
{
"cells": [
{
"cell_type": "code",
"source": [
"print(\"Hello World\")"
],
"metadata": {},
"outputs": [],
"execution_count": null
}
],
"metadata": {
"kernelspec": {},
"language_info": {}
},
"nbformat": 4,
"nbformat_minor": 2
}
```
This happened because we were writing cell metadata to the system
clipboard instead of the cell contents. We should have only been writing
the cell contents to the system clipboard.
### Screenshots
**copy/paste single cell into cell editor**
https://github.com/user-attachments/assets/d9b869c1-e8d1-4a9d-a052-b257a5fb6ba2
**copy/paste multiple cells into cell editor**
https://github.com/user-attachments/assets/e262a21b-206f-4c02-a179-56fc23b8d7f7
**copy/paste multiple cells into non-notebook editor**
https://github.com/user-attachments/assets/70f9c22c-ca65-4c4c-898d-1afcefda66f3
**copy/paste cells into a different notebook**
https://github.com/user-attachments/assets/64047f2e-1740-4282-a2a5-e4941dd155fd
### Release Notes
<!--
Optionally, replace `N/A` with text to be included in the next release
notes.
The `N/A` bullets are ignored. If you refer to one or more Positron
issues,
these issues are used to collect information about the feature or
bugfix, such
as the relevant language pack as determined by Github labels of type
`lang: `.
The note will automatically be tagged with the language.
These notes are typically filled by the Positron team. If you are an
external
contributor, you may ignore this section.
-->
#### New Features
- N/A
#### Bug Fixes
- N/A
### QA Notes
@:positron-notebooks
- Copy cell and paste anywhere in a notebook -> pastes new cell with
metadata
- Copy cell and paste within a cell -> paste just the source text
- Copy cell and paste into a non .ipynb file -> paste just the source
text
---------
Signed-off-by: Dhruvi Sompura <[email protected]>
Co-authored-by: Nick Strayer <[email protected]>1 parent 9dadae4 commit 689c28e
File tree
4 files changed
+69
-170
lines changed- src/vs/workbench/contrib/positronNotebook/browser
- test/e2e/tests/notebooks-positron
4 files changed
+69
-170
lines changedLines changed: 19 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
| 41 | + | |
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| |||
1440 | 1440 | | |
1441 | 1441 | | |
1442 | 1442 | | |
1443 | | - | |
1444 | | - | |
1445 | | - | |
1446 | | - | |
1447 | | - | |
1448 | 1443 | | |
1449 | 1444 | | |
1450 | 1445 | | |
| |||
1456 | 1451 | | |
1457 | 1452 | | |
1458 | 1453 | | |
1459 | | - | |
1460 | | - | |
| 1454 | + | |
| 1455 | + | |
| 1456 | + | |
| 1457 | + | |
| 1458 | + | |
| 1459 | + | |
| 1460 | + | |
| 1461 | + | |
| 1462 | + | |
1461 | 1463 | | |
1462 | | - | |
1463 | | - | |
| 1464 | + | |
| 1465 | + | |
| 1466 | + | |
1464 | 1467 | | |
1465 | 1468 | | |
1466 | 1469 | | |
| |||
1500 | 1503 | | |
1501 | 1504 | | |
1502 | 1505 | | |
| 1506 | + | |
| 1507 | + | |
| 1508 | + | |
1503 | 1509 | | |
1504 | 1510 | | |
1505 | 1511 | | |
1506 | | - | |
| 1512 | + | |
1507 | 1513 | | |
1508 | 1514 | | |
1509 | 1515 | | |
| |||
1522 | 1528 | | |
1523 | 1529 | | |
1524 | 1530 | | |
1525 | | - | |
| 1531 | + | |
1526 | 1532 | | |
1527 | 1533 | | |
1528 | 1534 | | |
| |||
1560 | 1566 | | |
1561 | 1567 | | |
1562 | 1568 | | |
1563 | | - | |
| 1569 | + | |
1564 | 1570 | | |
1565 | 1571 | | |
1566 | 1572 | | |
| |||
Lines changed: 1 addition & 148 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
8 | | - | |
| 7 | + | |
9 | 8 | | |
10 | 9 | | |
11 | 10 | | |
| |||
32 | 31 | | |
33 | 32 | | |
34 | 33 | | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
Lines changed: 41 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| |||
58 | 59 | | |
59 | 60 | | |
60 | 61 | | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
61 | 85 | | |
62 | 86 | | |
63 | 87 | | |
| |||
75 | 99 | | |
76 | 100 | | |
77 | 101 | | |
| 102 | + | |
78 | 103 | | |
79 | 104 | | |
80 | 105 | | |
| |||
122 | 147 | | |
123 | 148 | | |
124 | 149 | | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
125 | 166 | | |
126 | 167 | | |
127 | 168 | | |
| |||
Lines changed: 8 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
143 | | - | |
144 | 143 | | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
153 | 152 | | |
154 | 153 | | |
155 | 154 | | |
| |||
0 commit comments