Skip to content

Commit

Permalink
Fix Shift + L not working in stdin (#15440)
Browse files Browse the repository at this point in the history
* Add a test case against shortcuts intercepting stdin typing

This currently fails with:
  Expected string: "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
  Received string: "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKMNOPQRSTUVWXYZ0123456789"

* Add missing `:not(:read-write)` selector for Shift+L

* Remove duplicated shortcut for `notebook:toggle-all-cell-line-numbers`
  • Loading branch information
krassowski committed Nov 28, 2023
1 parent 54e785f commit 8405524
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 6 deletions.
30 changes: 30 additions & 0 deletions galata/test/jupyterlab/outputarea-stdin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@

import { expect, test } from '@jupyterlab/galata';

test.use({
locale: 'en-US'
});

test.describe('Stdin for ipdb', () => {
test.beforeEach(async ({ page }) => {
await page.notebook.createNew();
Expand Down Expand Up @@ -52,4 +56,30 @@ test.describe('Stdin for ipdb', () => {
await page.keyboard.insertText('x');
await expect(page.locator('.jp-Stdin-input')).toHaveValue('foofoox');
});

test('Typing in stdin box', async ({ page }) => {
// Test to ensure that notebook shortcuts do not capture text typed into inputs.
// This may not be sufficient to ensure no conflicts with other languages but
// should catch the most severe issues.
const alphabet = 'abcdefghijklmnopqrstuvwxyz';
const digits = '0123456789';
await page.notebook.setCell(0, 'code', 'input()');
// Run the selected (only) cell without proceeding and without waiting
// for it to complete (as it should stay waiting for input).
await page.keyboard.press('Control+Enter');

await page.waitForSelector('.jp-Stdin-input');
for (const letter of alphabet) {
await page.keyboard.press(`Key${letter.toUpperCase()}`);
}
for (const letter of alphabet) {
await page.keyboard.press(`Shift+Key${letter.toUpperCase()}`);
}
for (const digit of digits) {
await page.keyboard.press(`Digit${digit}`);
}
await expect(page.locator('.jp-Stdin-input')).toHaveValue(
alphabet + alphabet.toUpperCase() + digits
);
});
});
7 changes: 1 addition & 6 deletions packages/notebook-extension/schema/tracker.json
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@
{
"command": "viewmenu:line-numbering",
"keys": ["Shift L"],
"selector": ".jp-Notebook.jp-mod-commandMode"
"selector": ".jp-Notebook.jp-mod-commandMode :focus:not(:read-write)"
},
{
"command": "viewmenu:match-brackets",
Expand All @@ -628,11 +628,6 @@
"keys": ["Ctrl Shift -"],
"selector": ".jp-Notebook.jp-mod-editMode"
},
{
"command": "notebook:toggle-all-cell-line-numbers",
"keys": ["Shift L"],
"selector": ".jp-Notebook.jp-mod-commandMode :focus:not(:read-write)"
},
{
"command": "notebook:undo-cell-action",
"keys": ["Z"],
Expand Down

0 comments on commit 8405524

Please sign in to comment.