Main issue
Cursor position is a font-size based calculation which currently assumes that the browser is rendering 7px wide characters (Ubuntu Mono). When this is not the case (for example you run in a browser outside of the Linux/Ubuntu OS) the cursor position doesn't correspond to the true position.
Easiest way to see this is to play around with the text editor in the ODB web test.
possible solution
One possible way to grab the text width live is by using the API for the canvas element, like so:
let canvas = document.createElement("canvas"));
let context = canvas.getContext("2d");
context.font = font;
let metrics = context.measureText(text);
let textWidth = metrics.width;
Main issue
Cursor position is a font-size based calculation which currently assumes that the browser is rendering 7px wide characters (Ubuntu Mono). When this is not the case (for example you run in a browser outside of the Linux/Ubuntu OS) the cursor position doesn't correspond to the true position.
Easiest way to see this is to play around with the text editor in the ODB web test.
possible solution
One possible way to grab the text width live is by using the API for the
canvaselement, like so: