File tree Expand file tree Collapse file tree 2 files changed +38
-2
lines changed Expand file tree Collapse file tree 2 files changed +38
-2
lines changed Original file line number Diff line number Diff line change @@ -126,8 +126,12 @@ def process_message(message)
126
126
if message [ :id ]
127
127
# If a document is deleted before we are able to process all of its enqueued requests, we will try to read it
128
128
# from disk and it raise this error. This is expected, so we don't include the `data` attribute to avoid
129
- # reporting these to our telemetry
130
- if e . is_a? ( Store ::NonExistingDocumentError )
129
+ # reporting these to our telemetry.
130
+ #
131
+ # Similarly, if we receive a location for an invalid position in the
132
+ # document, we don't report it to telemetry
133
+ case e
134
+ when Store ::NonExistingDocumentError , Document ::InvalidLocationError
131
135
send_message ( Error . new (
132
136
id : message [ :id ] ,
133
137
code : Constant ::ErrorCodes ::INVALID_PARAMS ,
Original file line number Diff line number Diff line change @@ -1567,6 +1567,38 @@ def version
1567
1567
end
1568
1568
end
1569
1569
1570
+ def test_invalid_location_errors_are_not_reported_to_telemetry
1571
+ uri = URI ::Generic . from_path ( path : "/foo.rb" )
1572
+
1573
+ @server . process_message ( {
1574
+ method : "textDocument/didOpen" ,
1575
+ params : {
1576
+ textDocument : {
1577
+ uri : uri ,
1578
+ text : "class Foo\n end" ,
1579
+ version : 1 ,
1580
+ languageId : "ruby" ,
1581
+ } ,
1582
+ } ,
1583
+ } )
1584
+
1585
+ @server . push_message ( {
1586
+ id : 1 ,
1587
+ method : "textDocument/definition" ,
1588
+ params : {
1589
+ textDocument : {
1590
+ uri : uri ,
1591
+ } ,
1592
+ position : { line : 10 , character : 6 } ,
1593
+ } ,
1594
+ } )
1595
+
1596
+ error = find_message ( RubyLsp ::Error )
1597
+ attributes = error . to_hash [ :error ]
1598
+ assert_nil ( attributes [ :data ] )
1599
+ assert_match ( "Document::InvalidLocationError" , attributes [ :message ] )
1600
+ end
1601
+
1570
1602
private
1571
1603
1572
1604
def wait_for_indexing
You can’t perform that action at this time.
0 commit comments