@@ -548,7 +548,11 @@ internal.oldfiles = function(opts)
548548 local current_file = api .nvim_buf_get_name (current_buffer )
549549 local results = {}
550550
551- if utils .iswin then -- for slash problem in windows
551+ local function has_protocol (path )
552+ return string.match (path , " ^[A-z0-9]+://" )
553+ end
554+
555+ if utils .iswin and not has_protocol (current_file ) then -- for slash problem in windows
552556 current_file = current_file :gsub (" /" , " \\ " )
553557 end
554558
@@ -558,22 +562,28 @@ internal.oldfiles = function(opts)
558562 local open_by_lsp = string.match (buffer , " line 0$" )
559563 if match and not open_by_lsp then
560564 local file = api .nvim_buf_get_name (match )
565+ local protocol = has_protocol (file )
561566 if utils .iswin then
562567 file = file :gsub (" /" , " \\ " )
563568 end
564- if vim .uv .fs_stat (file ) and match ~= current_buffer then
569+ if match ~= current_buffer and ( protocol or vim .uv .fs_stat (file )) then
565570 table.insert (results , file )
566571 end
567572 end
568573 end
569574 end
570575
571576 for _ , file in ipairs (vim .v .oldfiles ) do
577+ local protocol = has_protocol (file )
572578 if utils .iswin then
573579 file = file :gsub (" /" , " \\ " )
574580 end
575- local file_stat = vim .uv .fs_stat (file )
576- if file_stat and file_stat .type == " file" and not vim .tbl_contains (results , file ) and file ~= current_file then
581+ local file_stat = vim .loop .fs_stat (file )
582+ if
583+ ((file_stat and file_stat .type == " file" ) or (protocol and protocol ~= " file://" and protocol ~= " term://" ))
584+ and not vim .tbl_contains (results , file )
585+ and file ~= current_file
586+ then
577587 table.insert (results , file )
578588 end
579589 end
0 commit comments