@@ -2,6 +2,7 @@ local api, uv, ffi, Iter = vim.api, vim.uv, require('ffi'), vim.iter
22local FileOps = require (' dired.fileops' )
33local ns_id = api .nvim_create_namespace (' dired_highlights' )
44local ns_cur = api .nvim_create_namespace (' dired_cursor' )
5+ local SEPARATOR = vim .uv .os_uname ().sysname :match (' win' ) and ' /' or ' \\ '
56
67-- FFI definitions
78ffi .cdef ([[
@@ -259,7 +260,7 @@ UI.Entry = {
259260 user = Format .username (entry .stat .uid ),
260261 size = Format .size (entry .stat .size ),
261262 time = os.date (' %Y-%m-%d %H:%M' , entry .stat .mtime .sec ),
262- name = entry .name .. (entry .stat .type == ' directory' and ' / ' or ' ' ),
263+ name = entry .name .. (entry .stat .type == ' directory' and SEPARATOR or ' ' ),
263264 }
264265
265266 return string.format (
@@ -434,7 +435,8 @@ Browser.State = {
434435 api .nvim_buf_attach (s .search_buf , false , {
435436 on_lines = function ()
436437 -- Get search text without prompt path
437- local text = api .nvim_get_current_line ():gsub (s .current_path , ' ' ):gsub (' ^/' , ' ' )
438+ local text =
439+ api .nvim_get_current_line ():gsub (s .current_path , ' ' ):gsub (' ^' .. SEPARATOR , ' ' )
438440
439441 -- Clear previous timer if exists
440442 if timer :is_active () then
@@ -446,7 +448,7 @@ Browser.State = {
446448 200 ,
447449 0 ,
448450 vim .schedule_wrap (function ()
449- if text :match (' / $' ) then
451+ if text :match (SEPARATOR .. ' $' ) then
450452 return
451453 end
452454 if text and # text > 0 then
@@ -929,7 +931,8 @@ Browser.refresh = function(state, path)
929931 updateHighlights ()
930932 Browser .update_current_hl (state , 2 )
931933
932- local new_path = not state .current_path :find (' /$' ) and state .current_path .. ' /'
934+ local new_path = not state .current_path :find (SEPARATOR .. ' $' )
935+ and state .current_path .. SEPARATOR
933936 or state .current_path
934937 vim .fn .prompt_setprompt (state .search_buf , new_path )
935938 local pos = api .nvim_win_get_cursor (state .search_win )
0 commit comments