Skip to content

Code Editor Highlights Wrong Line on Indentation Error #5838

@rossop

Description

@rossop

Bug Report for https://neetcode.io/problems/replace-elements-with-greatest-element-on-right-side

When a Python script fails compilation due to a TabError: inconsistent use of tabs and spaces in indentation, the code editor highlights and applies error UI formatting to the wrong line number. It highlights the line above the actual offending line.

Browser: 1.19.13b (Firefox 150.0.3) (aarch64) Zen Broser

This is the second time I have found this error on the platform.

Current Fix

Copy and paste solution from another editor.

Steps to Reproduce

  1. Open a problem on NeetCode.io (e.g., Leetcode 1299).
  2. Write a Python code snippet manually.
  3. Run the code to trigger a TabError.

Expected Result

  • Console Output: Identifies line 6 as the issue (File "/box/main.py", line 6...).
  • Code Editor UI: The red error background block, the red squiggly line all appear on Line 6, where the error occurs.

Actual Result

  • Console Output: Correctly identifies the error is on line 6
  • Code Editor UI: The editor visually highlights Line 6 (rightMax: int = -1)

Visual Evidence

In the provided screenshot:

  • The Editor (Top): Line 6 is highlighted in a dark red block with a bright red warning bar on the right side.
  • The Console (Bottom): The Python interpreter trace explicitly points to the line below it: File "/box/main.py", line 6 rightMax: int = -1 ^ TabError: inconsistent use of tabs and spaces in indentation
Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions