Fix Invalid Point error when opening files without position#1412
Open
asiloisad wants to merge 2 commits intopulsar-edit:masterfrom
Open
Fix Invalid Point error when opening files without position#1412asiloisad wants to merge 2 commits intopulsar-edit:masterfrom
asiloisad wants to merge 2 commits intopulsar-edit:masterfrom
Conversation
Contributor
Author
|
The test was failing because |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes
TypeError: Invalid Point: (null, null)andInvalid Point: (null, Infinity)errors that occur when opening files without explicitinitialLine/initialColumnoptions.This commonly happens when opening files outside the current project (e.g., via recent files, drag-and-drop, or external tools).
The Problem
The validation in
workspace.open()used!Number.isNaN()to check if position options were provided:This is broken because:
Number.isNaN(null)→false!Number.isNaN(null)→true(enters the block)initialLine = null(assigns null)null >= 0→true(JavaScript coercion)setCursorBufferPosition([null, null])→ ErrorThe Fix
Replace with
Number.isFinite()which correctly rejectsnull,undefined,NaN, andInfinity:This also fixes a secondary issue where the condition
initialLine >= 0 || initialColumn >= 0was always true (since defaults were 0), causing unnecessary cursor positioning on every file open.