How to update the displayed value after changing the cell value in a script?

I have a script to increment cell values which correctly does as much, however the displayed value is not updated (it only displays correctly in the formula bar). Using Data -> Refresh Range updates the display but it is cumbersome and refreshes the data for the whole sheet which can take a while for large sheets and it replaces the current selection.

Ideally i would like to work the refresh logic into the script. How can i do that if at all?


The script currently looks like this:

importClass(Packages.com.sun.star.uno.UnoRuntime);
importClass(Packages.com.sun.star.table.XCell);
importClass(Packages.com.sun.star.frame.XModel);

var model = UnoRuntime.queryInterface(XModel, XSCRIPTCONTEXT.getInvocationContext());
var selection = model.getCurrentSelection();
var cell = UnoRuntime.queryInterface(XCell, selection);
cell.setValue(cell.getValue() + 1);

Edit: This only appears to be an issue in Windows, it updates instantly in Debian. (I cannot confirm if the versions were the same though.)