File tree Expand file tree Collapse file tree 3 files changed +51
-12
lines changed
Expand file tree Collapse file tree 3 files changed +51
-12
lines changed Original file line number Diff line number Diff line change @@ -1549,20 +1549,9 @@ impl Inner {
15491549 _token : & CancellationToken ,
15501550 ) -> LspResult < Option < Vec < TextEdit > > > {
15511551 let mark = self . performance . mark_with_args ( "lsp.formatting" , & params) ;
1552- // Untitled files are exempt from enabled-checks because they tend not to
1553- // have meaningful paths, and they won't be auto-formatted on save anyway.
1554- let is_untitled = params
1555- . text_document
1556- . uri
1557- . scheme ( )
1558- . is_some_and ( |s| s. eq_lowercase ( "untitled" ) ) ;
15591552 let Some ( document) = self . get_document (
15601553 & params. text_document . uri ,
1561- if is_untitled {
1562- Enabled :: Ignore
1563- } else {
1564- Enabled :: Filter
1565- } ,
1554+ Enabled :: Ignore ,
15661555 Exists :: Enforce ,
15671556 Diagnosable :: Ignore ,
15681557 ) ?
@@ -1574,6 +1563,13 @@ impl Inner {
15741563 } ;
15751564 let fmt_config =
15761565 self . config . tree . fmt_config_for_specifier ( & module. specifier ) ;
1566+ // Untitled files are exempt from enabled-checks because they tend not to
1567+ // have meaningful paths, and they won't be auto-formatted on save anyway.
1568+ let is_untitled = params
1569+ . text_document
1570+ . uri
1571+ . scheme ( )
1572+ . is_some_and ( |s| s. eq_lowercase ( "untitled" ) ) ;
15771573 if !is_untitled && !fmt_config. files . matches_specifier ( & module. specifier ) {
15781574 return Ok ( None ) ;
15791575 }
Original file line number Diff line number Diff line change @@ -132,6 +132,7 @@ pub fn uri_to_url(uri: &Uri) -> Url {
132132 if !scheme. eq_lowercase ( "untitled" )
133133 && !scheme. eq_lowercase ( "vscode-notebook-cell" )
134134 && !scheme. eq_lowercase ( "deno-notebook-cell" )
135+ && !scheme. eq_lowercase ( "vscode-userdata" )
135136 {
136137 return None ;
137138 }
@@ -157,4 +158,5 @@ pub fn uri_is_file_like(uri: &Uri) -> bool {
157158 || scheme. eq_lowercase ( "untitled" )
158159 || scheme. eq_lowercase ( "vscode-notebook-cell" )
159160 || scheme. eq_lowercase ( "deno-notebook-cell" )
161+ || scheme. eq_lowercase ( "vscode-userdata" )
160162}
Original file line number Diff line number Diff line change @@ -11798,6 +11798,47 @@ fn lsp_format_json() {
1179811798 client. shutdown ( ) ;
1179911799}
1180011800
11801+ #[ test]
11802+ #[ timeout( 300_000 ) ]
11803+ fn lsp_format_vscode_userdata ( ) {
11804+ let context = TestContextBuilder :: new ( ) . use_temp_cwd ( ) . build ( ) ;
11805+ let mut client = context. new_lsp_command ( ) . build ( ) ;
11806+ client. initialize_default ( ) ;
11807+ client. did_open_raw ( json ! ( {
11808+ "textDocument" : {
11809+ "uri" : "vscode-userdata:///a/settings.json" ,
11810+ "languageId" : "jsonc" ,
11811+ "version" : 1 ,
11812+ "text" : " // foo\n {}\n " ,
11813+ }
11814+ } ) ) ;
11815+ let res = client. write_request (
11816+ "textDocument/formatting" ,
11817+ json ! ( {
11818+ "textDocument" : {
11819+ "uri" : "vscode-userdata:///a/settings.json" ,
11820+ } ,
11821+ "options" : {
11822+ "tabSize" : 2 ,
11823+ "insertSpaces" : true ,
11824+ } ,
11825+ } ) ,
11826+ ) ;
11827+ assert_eq ! (
11828+ res,
11829+ json!( [
11830+ {
11831+ "range" : {
11832+ "start" : { "line" : 0 , "character" : 0 } ,
11833+ "end" : { "line" : 0 , "character" : 2 } ,
11834+ } ,
11835+ "newText" : "" ,
11836+ } ,
11837+ ] ) ,
11838+ ) ;
11839+ client. shutdown ( ) ;
11840+ }
11841+
1180111842#[ test]
1180211843#[ timeout( 300_000 ) ]
1180311844fn lsp_format_editor_options ( ) {
You can’t perform that action at this time.
0 commit comments