Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8171130

jshell tool: /edit adds empty statement to brace terminated snippet

    XMLWordPrintable

Details

    • b154
    • generic
    • generic
    • Verified

    Backports

      Description

        Reproducing Paul's report (below) with internal and external editor --

        jshell> /rese
        | Resetting state.

        jshell> if (45 < 72) { printf("45 < 72%n"); }
        45 < 72

        jshell> /ed

        jshell> /li

           1 : if (45 < 72) { printf("45 < 72%n"); }
           2 : if (45 > 72) { printf("45 > 72%n"); }
           3 : ;

        jshell> /drop 2 3

        jshell> /set editor kwrite
        | Editor set to: kwrite

        jshell> /ed

        jshell> /li

           1 : if (45 < 72) { printf("45 < 72%n"); }
           4 : if (45 > 72) { printf("45 > 72%n"); }
           5 : ;

        jshell>

        -----

        On 12/10/16 04:56, Paul Deitel wrote:
        I just noticed that when I edit a multiline if statement as in my email below. Edit Pad displays the if statement with a terminating ; as in

        if (45 < 72) {
             printf("45 < 72%n");
        };

        I assume this is where the extra statement is coming from.

        We should not be adding a semicolon to the closing } of the statement.


        On Dec 9, 2016, at 8:51 PM, Paul Deitel wrote:

        One more thing: Even if the line after the closing brace has an actual statement on it, the separate snippet containing just a semicolon appears in the /list between the if statement and the other actual statement.



        On Dec 9, 2016, at 8:47 PM, Paul Deitel wrote:

        I would definitely remove one button and just have Cancel and “Accept and Exit”

        Separately though, I had the following interaction:

        jshell> if (45 < 72) {
          ...> printf("45 < 72%n");
          ...> }
        45 < 72

        jshell> /edit 1

        jshell> /list

          1 : if (45 < 72) {
                 printf("45 < 72%n");
              }
          2 : if (45 > 72) {
                 printf("45 > 72%n");
              }
          3 : ;


        to produce the code snippet #2, I simply edited it in Edit Pad, changing only the two < operators in snippet 1 to >. When I clicked Exit, then listed the snippets I also get snippet 3 which is just a ;

        There is an extra blank line in Edit Pad following the snippet when you load it—it appears you guys are adding a semicolon to that line automatically, thus producing the extra snippet.

        Attachments

          Issue Links

            Activity

              People

                rfield Robert Field (Inactive)
                rfield Robert Field (Inactive)
                Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: