Skip to content

Commit

Permalink
Fix async function display (#16443)
Browse files Browse the repository at this point in the history
* updated regex

* added tests
  • Loading branch information
sanskriti2005 committed Jun 6, 2024
1 parent 2c718c1 commit eb1eca6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/fileeditor/src/toc/python.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ try {
// https://github.com/tc39/proposal-regexp-match-indices was accepted
// in May 2021 (https://github.com/tc39/proposals/blob/main/finished-proposals.md)
// So we will fallback to the polyfill regexp-match-indices if not available
KEYWORDS = new RegExp('^\\s*(class |def |from |import )', 'd');
KEYWORDS = new RegExp('^\\s*(class |def |async def |from |import )', 'd');
} catch {
KEYWORDS = new RegExp('^\\s*(class |def |from |import )');
KEYWORDS = new RegExp('^\\s*(class |def |async def |from |import )');
}

/**
Expand Down
10 changes: 10 additions & 0 deletions packages/fileeditor/test/python.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@ describe('@jupyterlab/fileeditor', () => {
}
]
],
[
'async def async_function():',
[
{
text: 'async def async_function():',
level: 1,
line: 0
}
]
],
[
'class Klass:',
[
Expand Down

0 comments on commit eb1eca6

Please sign in to comment.