@@ -56,10 +56,10 @@ def run
56
56
store . delete ( uri )
57
57
in { method : "textDocument/formatting" , id :, params : { textDocument : { uri : } } }
58
58
contents = store [ uri ]
59
- write ( id : id , result : contents ? [ format ( store [ uri ] , uri . split ( "." ) . last ) ] : nil )
59
+ write ( id : id , result : contents ? format ( contents , uri . split ( "." ) . last ) : nil )
60
60
in { method : "textDocument/inlayHint" , id :, params : { textDocument : { uri : } } }
61
61
contents = store [ uri ]
62
- write ( id : id , result : contents ? inlay_hints ( store [ uri ] ) : nil )
62
+ write ( id : id , result : contents ? inlay_hints ( contents ) : nil )
63
63
in { method : "syntaxTree/visualizing" , id :, params : { textDocument : { uri : } } }
64
64
write ( id : id , result : PP . pp ( SyntaxTree . parse ( store [ uri ] ) , +"" ) )
65
65
in { method : %r{\$ /.+} }
@@ -89,19 +89,25 @@ def capabilities
89
89
def format ( source , extension )
90
90
text = SyntaxTree ::HANDLERS [ ".#{ extension } " ] . format ( source , print_width )
91
91
92
- {
93
- range : {
94
- start : {
95
- line : 0 ,
96
- character : 0
92
+ [
93
+ {
94
+ range : {
95
+ start : {
96
+ line : 0 ,
97
+ character : 0
98
+ } ,
99
+ end : {
100
+ line : source . lines . size + 1 ,
101
+ character : 0
102
+ }
97
103
} ,
98
- end : {
99
- line : source . lines . size + 1 ,
100
- character : 0
101
- }
102
- } ,
103
- newText : text
104
- }
104
+ newText : text
105
+ }
106
+ ]
107
+ rescue Parser :: ParseError
108
+ # If there is a parse error, then we're not going to return any formatting
109
+ # changes for this source.
110
+ nil
105
111
end
106
112
107
113
def inlay_hints ( source )
0 commit comments