mugiwara85 / CodeblockCustomizer

Codeblock Customizer plugin for Obsidian
MIT License
147 stars 7 forks source link

[Bug] Plugin breaks diff highlighting in reading view #58

Closed cgarrard closed 4 months ago

cgarrard commented 9 months ago

Take this diff codeblock:

```diff
@@ -1 +1,2 @@
-print('hello world')
+for i in range(10):
+    print('hello world')


It displays correctly in edit mode:

![image](https://github.com/mugiwara85/CodeblockCustomizer/assets/4453816/61df80a2-62ac-436f-a38d-f71cfa857291)

But only the first added line is green when in reading mode:

![image](https://github.com/mugiwara85/CodeblockCustomizer/assets/4453816/d04e0db1-13b3-4f9e-b043-df75c39bd735)

If I disable the plugin then it displays as expected in the reading view:

![image](https://github.com/mugiwara85/CodeblockCustomizer/assets/4453816/8929f252-b6b7-4a9e-936a-85a48eab7193)

I'm using the Things theme, but I tried using the default theme and that didn't change anything. Disabling line numbers didn't help either.

Thank you for creating this plugin-- I really like it!
mugiwara85 commented 9 months ago

I will look at it. Thanks for the sample code block

ColinOppenheim commented 7 months ago

I'm having the same problem: image Here is the same content in reading view: image

However disabling the plugin and then re enabling it hides all the content T had modified in reading view. I have to go into edit mode. Cut all the content and repaste and then it shows up with the same issue as shown above; however, I decided to remove the hl:3 from the code block since it wasn't working so the code block looks like this now: image

But when I switch back to reading mode: Voila! image

Yea i have no idea why. I don't have many plugins enabled just one or two and this is the only one that provides any level of visual enhancement. If it helps your troubleshooting i have included my current settings for the plugin below: data.json

I'm using a Theme marked as (Legacy) called Tokyo Night... not sure if that has anything to do with it... Hope this information helps you figure it out.

mugiwara85 commented 7 months ago

I'm having the same problem: image Here is the same content in reading view: image

However disabling the plugin and then re enabling it hides all the content T had modified in reading view. I have to go into edit mode. Cut all the content and repaste and then it shows up with the same issue as shown above; however, I decided to remove the hl:3 from the code block since it wasn't working so the code block looks like this now: image

But when I switch back to reading mode: Voila! image

Yea i have no idea why. I don't have many plugins enabled just one or two and this is the only one that provides any level of visual enhancement. If it helps your troubleshooting i have included my current settings for the plugin below: data.json

I'm using a Theme marked as (Legacy) called Tokyo Night... not sure if that has anything to do with it... Hope this information helps you figure it out.

Yeah, the info definitely helps to debug. Can you please send the code block as well, so I can reproduce it exactly? This might actually be two problems. I will look at it, what could be the problem.

ColinOppenheim commented 7 months ago

These are two code blocks I attempted to highlight...

FXMLLoader loader = new FXMLLoader(getClass().getResource("/Views/NextScreen.fxml"));  
Parent root = loader.load();  
Stage stage = (Stage) ((Button) event.getSource()).getScene().getWindow();  
stage.setScene(new Scene(root));  
stage.show();
FXMLLoader loader = new FXMLLoader(getClass().getResource("/Views/NextScreen.fxml"));  
Parent root = loader.load();  
Stage stage = (Stage) ((Button) event.getSource()).getScene().getWindow();  
Utility.rememberPosition(stage);  
stage.setScene(new Scene(root));  
Utility.centerScreen(stage);  
stage.setTitle("Appointment Scheduler");  
stage.show();

Just a heads up i played around with the problem a little more and was able to get it to display correctly without having to disable and re-enable to plugin.

What i ended up doing was I selected everything in the code block and cut it to clipboard leaving the just the java block and line settings like this: image Then I switch back to reading mode so the code block looks like this: image Then I switch back into edit mode and replace the code i had cut to clipboard, and when I switch back to reading mode it looks the way it should! image

So the issue seems to have something to do with refreshing the view maybe? Hope this helps.

mugiwara85 commented 4 months ago

This is fixed now. It will be available in the next release.

mugiwara85 commented 4 months ago

Fixed in current release (1.2.6). Should there be any problems please report back.