This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 268412

Summary: Support for items in /list
Product: java Reporter: Geertjan Wielenga <geertjan>
Component: JShellAssignee: Svata Dedic <sdedic>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P2    
Version: Dev   
Hardware: PC   
OS: Windows 7   
Issue Type: DEFECT Exception Reporter:

Description Geertjan Wielenga 2016-10-07 21:25:49 UTC
When you use /list, you properly see the valid snippets you’ve entered so far. But when you then use

/1
/2

etc. to execute the snippets you’ve typed so far, it instead executes the default imports that are loaded when the session starts.
Comment 1 Paul Deitel 2016-10-16 13:09:57 UTC
This is related to the bug that’s already filed about /# executing the wrong snippet.

I was looking at JShell in NetBeans again this morning and noticed your prompt is

	[#] ->

The first # displayed is 9, which I assume is because it’s treating JShell’s default imports and printf definition as 1-8. That is different from how JShell does it, where the first snippet you enter is #1. 

Another difference I noticed is that command-line JShell numbers only VALID snippets sequentially. So, for example, if you enter a valid snippet, followed by a snippet with an error, followed by another valid snippet, the two valid snippets are numbered 1 and 2 and the invalid one is e1. If you then execute /2, the second VALID snippet is recalled, not the one with the error that was typed second.

In NetBeans, /# always recalls the snippet based on the number in the [#] -> prompt.

I believe this work the same as in command-line JShell.
Comment 2 Svata Dedic 2016-12-01 15:42:28 UTC
/n history command should now reexecute snippet "n" (as seen in /list command). Prompt numbers correspond to snippet numbers.