Auto format icon no longer appears in Java

Bug description:

The auto format icon no longer appears in Java replits.

Expected vs Current Behavior:

I expect the auto format icon to appear in the editor for a Java replit, but it does not.

Steps to reproduce:

Create a Java replit. Look for the auto format icon.

Bug appears at this link:

n/a

Screenshot(s)/Screen Recording:

n/a

Browser/OS/Device: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36

My students all report the same problem on their various operating systems and browsers.

Replit Profile: https://replit.com/@

Please send me the link to your repl and I’ll take a look

1 Like

Thank you! It happens with every Java replit. Here’s one: https://replit.com/@espertusnu/TroubleWithAutoFormat

Yeah Idk, the format code button is very inconsistent. Sometimes it shows up. Other times it doesn’t.

But you can press Ctrl + S to format.

2 Likes

The format button appeared for me. If it doesn’t work, make sure your replit.nix file looks like this:

{ pkgs }: {
    deps = [
        pkgs.graalvm17-ce
        pkgs.maven
        pkgs.replitPackages.jdt-language-server
        pkgs.replitPackages.java-debug
    ];
}

If the formatting button disappears after that, run kill 1 in the shell and that should work.

2 Likes

Thank you, but Ctrl + S does not have any effect for me (Chrome/Windows).

2 Likes

I have tried everything you suggested, and nothing works. As far as I can tell, it doesn’t work for any of my (90) students.

This video shows me trying all of your suggestions.

1 Like

Was the .replit file changed in any way in your repl? What happens when you create a brand new Java repl and try?

Do you have any browser extensions that could be getting in the way? If so, try disabling them + refreshing the workspace and see if the format button appears.

1 Like

The formatting button is not present even if there are no extensions enabled. See video: replit-again.mp4 - Google Drive

When did you make this video?

Also, wow thats a lot of notifs!
image

Anyways, it should be there now on the tab:
image

1 Like

And if it’s not on the tab, you’ll see an arrow. Click the arrow and you’ll see the format button.

1 Like

Does the button appear when you use your browser normally? (not in incognito mode)

I just looked in java and it’s not there. It might be because java doesn’t have a web view. I know that all webview-lang’s have one, so that might be why.

If you watch the full video, you can see she tries that as well.

Here’s something I came up with that might fix the issue. Let me know if it worked for you!

1 Like

Bro my man has alllll the answers :skull:

Thank you. I created a new Java project, and my hidden files did have the references to jdt-language-server. I had not known about the new appearance of the formatter. The icon did show up in the Main.java tab, but it didn’t work. When I clicked on it, it spun for 10+ seconds without doing anything.
image

I then created another new project and ran jdt-language-server in the console, the icon showed up. Sometimes it works, but sometimes it spins without doing anything. Still, that’s major progress!

Are any of below warnings in the developer tools console significant?

I will share the console trick with my students

ed150ef9.29546453b08cd067.js:1 Canvas2D: Multiple readback operations using getImageData are faster with the willReadFrequently attribute set to true. See: https://html.spec.whatwg.org/multipage/canvas.html#concept-canvas-will-read-frequently
_parseColor @ ed150ef9.29546453b08cd067.js:1
ed150ef9.29546453b08cd067.js:1 Canvas2D: Multiple readback operations using getImageData are faster with the willReadFrequently attribute set to true. See: https://html.spec.whatwg.org/multipage/canvas.html#concept-canvas-will-read-frequently
_parseColor @ ed150ef9.29546453b08cd067.js:1
9421.96c6d46ada126ea5.js:1 Canvas2D: Multiple readback operations using getImageData are faster with the willReadFrequently attribute set to true. See: https://html.spec.whatwg.org/multipage/canvas.html#concept-canvas-will-read-frequently
_drawToCache @ 9421.96c6d46ada126ea5.js:1
9421.96c6d46ada126ea5.js:1 Canvas2D: Multiple readback operations using getImageData are faster with the willReadFrequently attribute set to true. See: https://html.spec.whatwg.org/multipage/canvas.html#concept-canvas-will-read-frequently
_drawToCache @ 9421.96c6d46ada126ea5.js:1
DevTools failed to load source map: Could not load content for https://cdn.replit.com/_next/static/css/19187292e50ac885.css.map: HTTP error: status code 404, net::ERR_HTTP_RESPONSE_CODE_FAILURE

Unfortunately I’m not very familiar with java or the LSP server, so I’m not sure about the warnings.

If the formatter spins like that, try reloading the page or running kill 1 in the shell to force a repl reboot and see if it works.

1 Like

This issue is also happening to me and my students. What has worked for us in most cases is showing hidden files, closing Main.java, opening Main.class, then open Main.java and it usually appears…