javascriptmonaco-editor

How to get the horizontal position (left offset) for the colunm in monaco editor?


I need to convert the [lineNmber, column] coordinate to [x, y] pixel coordinate to the top-left, and I found API getTopForLineNumber and getTopForPosition to convert the lineNumber to vertical pixel coordinate, but I didn't find any API to convert column to horizontal pixel coordinate. Is there any method to convert column to horizontal pixel coordinate?


Solution

  • Try the getOffsetForColumn method to get an offset for the column from the beginning of the line.