Repository navigation
Return false from TextDocumentFilter.is and TextDocumentRegistrationOptions.is for null/undefined - #1941
Open
Pujitha Paladugu (pujitha24) wants to merge 1 commit into
Open
Return false from TextDocumentFilter.is and TextDocumentRegistrationOptions.is for null/undefined#1941Pujitha Paladugu (pujitha24) wants to merge 1 commit into
Pujitha Paladugu (pujitha24) wants to merge 1 commit into
Conversation
…ptions.is for null/undefined Motivation: TextDocumentFilter.is read candidate.language without checking that the candidate is an object, so TextDocumentFilter.is(null) and DocumentSelector.is([null]) threw a TypeError instead of returning false. TextDocumentRegistrationOptions.is(null) returned null rather than a boolean. Approach: Guard both functions with Is.objectLiteral, as the neighbouring NotebookDocumentFilter.is and NotebookCellTextDocumentFilter.is already do. String filters still short-circuit to true; behaviour for object inputs is unchanged. Validation: Added tests in protocol/src/node/test/documentFilter.test.ts. Before the fix three of them failed (two TypeErrors, one null !== false); after it `cd protocol && npm run compile && npm run test:node` reports 16 passing, and `npm run lint` in protocol is clean. Browser tests were not run, since only platform-independent guard logic changed. Report: microsoft#1939 Signed-off-by: Pujitha Paladugu <10557236+pujitha24@users.noreply.github.com> Assisted-by: claude-sonnet-5-5 (via Claude Code)
Dirk Bäumer (dbaeumer)
approved these changes
Nov 3, 2026
Dmitriy Vasyura (dmitrivMS)
approved these changes
Nov 3, 2026
Martin Aeschlimann (aeschli)
approved these changes
Nov 3, 2026
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.
Motivation:
TextDocumentFilter.is read candidate.language without checking that the
candidate is an object, so TextDocumentFilter.is(null) and
DocumentSelector.is([null]) threw a TypeError instead of returning false.
TextDocumentRegistrationOptions.is(null) returned null rather than a boolean.
Approach:
Guard both functions with Is.objectLiteral, as the neighbouring
NotebookDocumentFilter.is and NotebookCellTextDocumentFilter.is already do.
String filters still short-circuit to true; behaviour for object inputs is
unchanged.
Validation:
Added tests in protocol/src/node/test/documentFilter.test.ts. Before the fix
three of them failed (two TypeErrors, one null !== false); after it
cd protocol && npm run compile && npm run test:nodereports 16 passing, andnpm run lintin protocol is clean. Browser tests were not run, since onlyplatform-independent guard logic changed.
Report: #1939
Signed-off-by: Pujitha Paladugu 10557236+pujitha24@users.noreply.github.com
Assisted-by: claude-sonnet-5-5 (via Claude Code)
Fixes #1939