Repository navigation
Fix shell-line diagnostics and cancelled input prompts - #127
Merged
Merged
Conversation
Python cells marked `!cmd` and `%pip` lines as syntax errors in the editor, because diagnostics checked the raw cell rather than the source execution compiles. The diagnostics request now applies the same shorthand rewrite first, line for line, so positions are unchanged and the lines are still reported when shell escapes are turned off. Dismissing an input prompt in VS Code failed the cell instead of returning null, as the input contract and the docs promise and as `verso serve` already does. The host now answers a dismissed prompt with null, which fixes Console.ReadLine, GetInputAsync and GetPasswordAsync in C# and the F# reader at once. Interrupting a cell that is waiting at a prompt still cancels the request and stops the cell. Signed-off-by: Torrey Betts <torrey.betts@gmail.com>
SummarySummary
CoverageVerso - 82.2%
Verso.Abstractions - 84.2%
Verso.Ado - 81.4%
Verso.Blazor - 31.4%
Verso.Blazor.Shared - 62.6%
Verso.Cli - 41.4%
Verso.DataFrame - 82.3%
Verso.FSharp - 81.9%
Verso.Host - 58.7%
Verso.Http - 76.2%
Verso.JavaScript - 59.8%
Verso.PowerShell - 64.7%
Verso.Python - 78.1%
Verso.Sample.Diagram - 80.1%
Verso.Sample.Dice - 82.2%
Verso.Sample.Slides - 58.8%
Verso.Sample.Sparkline - 67.3%
Verso.Testing - 79.4%
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two bugs found while checking coverage ahead of the next release.
Python
!cmdand%piplines were marked as syntax errors. Editor diagnostics checked the raw cell, but execution rewrites those shorthand lines first, so every notebook with a!pip installline showed a red squiggle on it. The diagnostics request now applies the same rewrite before checking. It works line by line, so reported positions don't move, and when shell escapes are turned off the lines are still reported, because they would fail to run.Dismissing an input prompt in VS Code failed the cell. The input contract and the language kernels guide both say a cancelled prompt gives
null, andverso servedoes that. The VS Code host cancelled the pending request instead, soConsole.ReadLine(),GetInputAsyncandGetPasswordAsyncthrew. The host now answers a dismissed prompt withnull. I fixed it in the host rather than in each reader because the host was the one breaking the contract, and this way every kernel gets the same answer. Interrupting a cell that is waiting at a prompt still cancels the request and stops the cell; there are tests for that in C#, F# and through the host.Tests added:
tests/versohost/test_intellisense.py: shell and pip lines aren't diagnostics, a real error after them keeps its line, and they are diagnostics again with escapes offDiagnosticsTests: the same two cases through the Python kernelInputResponseTests(new, Verso.Host.Tests): a cancelled response gives null; cancelling the caller still cancels; a C# cell gets null fromConsole.ReadLine,GetInputAsyncandGetPasswordAsync; interrupting a cell at a prompt stops itThe new host tests and the first two pytest cases fail without the fix.