rturner-edjuster opened a new issue, #5546:
URL: https://github.com/apache/netbeans/issues/5546

   ### Apache NetBeans version
   
   Apache NetBeans 16
   
   ### What happened
   
   This is almost the same issue as 
https://github.com/apache/netbeans/issues/3720.
   
   When Java code is automatically formatting a try-with-resources statement, 
if the resource is specified with the type `var` instead of a specific type, an 
additional space is injected before the `var` keyword.
   
   ### How to reproduce
   
   With a clean install of NetBeans 16 on MacOS 13.1, with the default Java 
code formatting settings (no changes to defaults after install, and no 
importing of previous version settings, and using a "new file", and no existing 
project:
   
   1. Create a new Java file:
   2. Replace all code with the following:
   ```
   import java.io.IOException;
   import java.nio.file.Files;
   import java.nio.file.Paths;
   
   public class NewClass {
   
       public void test() throws IOException {
           try (var br = Files.newBufferedReader(Paths.get("test"))) {
   
           }
       }
   }```
   3. Select "Format" from the "Source" menu and the code will be reformatted 
as:
   ```
   import java.io.IOException;
   import java.nio.file.Files;
   import java.nio.file.Paths;
   
   public class NewClass {
   
       public void test() throws IOException {
           try ( var br = Files.newBufferedReader(Paths.get("test"))) {
   
           }
       }
   }
   ```
   
   Note the additional space in `try ( var`.
   
   If you replace `var` with `BufferedReader`, the problem does not occur.
   
   ### Did this work correctly in an earlier version?
   
   Apache NetBeans 12.6 or earlier
   
   ### Operating System
   
   Mac OS X version 13.1 running on aarch64; UTF-8; en_CA (nb)
   
   ### JDK
   
   18.0.2; OpenJDK 64-Bit Server VM 18.0.2+9-FR
   
   ### Apache NetBeans packaging
   
   Apache NetBeans provided installer
   
   ### Anything else
   
   _No response_
   
   ### Are you willing to submit a pull request?
   
   No
   
   ### Code of Conduct
   
   Yes


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to