Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions src/text-editor-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -1227,15 +1227,24 @@ module.exports = class TextEditorComponent {
let decorationToMeasure = this.decorationsToMeasure.cursors.get(marker);
if (!decorationToMeasure) {
const isLastCursor = model.getLastCursor().getMarker() === marker;
const screenPosition = reversed ? screenRange.start : screenRange.end;
const { row, column } = screenPosition;
const rawScreenPosition = reversed ? screenRange.start : screenRange.end;
const { row } = rawScreenPosition;
let { column } = rawScreenPosition;

if (row < this.getRenderedStartRow() || row >= this.getRenderedEndRow())
return;

// Clamp column to line length to prevent cursor rendering at invalid
// positions due to intermittent timing issues with display layer updates
const lineLength = model.lineLengthForScreenRow(row);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You've moved the call to lineLengthForScreenRow earlier. This is fine.

The purpose of this comment is to make it clear for the record that:

  • requestHorizontalMeasurements does not do anything that could affect what is returned by model.lineLengthForScreenRow; it reads from the model but does not change it;
  • even if that weren't true, requestHorizontalMeasurements doesn't do any synchronous work; it just schedules work to be performed later.

Hence it's impossible that calling lineLengthForScreenRow earlier could result in a behavior change.

if (column > lineLength) {
column = lineLength;
}

const screenPosition = { row, column };
this.requestHorizontalMeasurement(row, column);
let columnWidth = 0;
if (model.lineLengthForScreenRow(row) > column) {
if (lineLength > column) {
columnWidth = 1;
this.requestHorizontalMeasurement(row, column + 1);
}
Expand Down
Loading