Skip to content

fix: initialize new historyfile with empty array#61

Open
tkappedev wants to merge 1 commit intoDrKJeff16:mainfrom
tkappedev:fix_new_historyfile
Open

fix: initialize new historyfile with empty array#61
tkappedev wants to merge 1 commit intoDrKJeff16:mainfrom
tkappedev:fix_new_historyfile

Conversation

@tkappedev
Copy link
Copy Markdown
Contributor

Checks

  • I have read the CONTRIBUTING.md file
  • I have tested my changes (if applicable)

Description

If the plugin is freshly installed, the new history file created is empty. This causes the following error after startup:

(project.util.history.read_history): Could not decode JSON data from history file! (`stat.size = 0`) 

When opening a .git repository this one:

Error in LspAttach Autocommands for "*":                                                                                                                                                                          
Lua callback: (project.util.history.write_history): Unable to decode JSON data!                                                                                                                                   
stack traceback:                                                                                                                                                                                                  
        [C]: in function 'error'                                                                                                                                                                                  
        .../pack/core/opt/project.nvim/lua/project/util/history.lua:682: in function 'write_history'                                                                                                              
        ...pack/site/pack/core/opt/project.nvim/lua/project/api.lua:477: in function 'on_buf_enter'                                                                                                               
        ...pack/site/pack/core/opt/project.nvim/lua/project/api.lua:223: in function <...pack/site/pack/core/opt/project.nvim/lua/project/api.lua:222>                                                            
        [C]: in function 'nvim_exec_autocmds'                                                                                                                                                                     
        /usr/share/nvim/runtime/lua/vim/lsp/client.lua:1152: in function 'on_attach'                                                                                                                              
        /usr/share/nvim/runtime/lua/vim/lsp/client.lua:613: in function ''                                                                                                                                        
        vim/_core/editor.lua: in function <vim/_core/editor.lua:0>     

This fix simply initializes newly created history files with an empty array

Changes

  • Changed lua/project/util/path.lua:278 from v.fs_write(fd, '') to uv.fs_write(fd, '[]')

@tkappedev tkappedev requested a review from DrKJeff16 as a code owner April 18, 2026 11:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant