Skip to content
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

Update to enable block comments in python and other languages that do… #16770

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

adityamali
Copy link

References

Fixes #16212 : Implements toggleComment if toggleBlock comment is unavailable for the language

Code changes

In Codemirror-extension replace uses of toggleBlockComment with a composite command which tries to run toggleBlockComment first and toggleComment second if the former did not succeed (or check if language data have commentTokens.block defined).

User-facing changes

Better block comment implementation for languages that do not support block comments exclusively.

… not support it.

Update to enable block comments in python and other languages that do not support block comments.  Replaced the use of toggleBlockComment with a composite command which tries to run toggleBlockComment first and toggleComment second if the former did not succeed.
Copy link

Thanks for making a pull request to jupyterlab!
To try out this branch on binder, follow this link: Binder

@JasonWeill
Copy link
Contributor

@adityamali Thank you for opening this PR! Sorry for the delay in responding. I noticed that some of the unit tests are failing, and they look related to your change. Could you please take a look? Thanks again!

@krassowski
Copy link
Member

Thank you for working on it @adityamali! Would you be willing to also add a test case following the existing test case for JS?

test('Should toggle a block comment on Alt + A', async ({ page }) => {
const currentDir = await page.filebrowser.getCurrentDirectory();
await page.contents.renameFile(
`${currentDir}/${DEFAULT_NAME}`,
`${currentDir}/untitled.js`
);
// Select "second" and "third"
await page.getByRole('textbox').getByText('second').last().dblclick();
await page.keyboard.press('Shift+ArrowDown');
// Toggle block comment
await page.keyboard.press('Alt+A');
expect(await getEditorText(page)).toBe('first\n/* second\nthird */');
});

@krassowski krassowski added this to the 4.4.0 milestone Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make the block comment work in Python (and other languages without block comments)
3 participants