zabel-xyz / local-history

local-history for vscode
MIT License
228 stars 36 forks source link

[bug] - can't save history #108

Open misaku opened 4 years ago

misaku commented 4 years ago

I try to use local history, but I can't. the history saves, but at the same time deletes the history. and I can't use that. but if i set a specific location it works, but not very well, it can be saved, but i need to go to the history path and in the file to compare.

zabel-xyz commented 4 years ago

I need some information: What is your platform ? Version of vscode ? Inside ? Settings ? Open file, folder, workspace ?

I know there is still problem with external path location, (compare, restore)

misaku commented 4 years ago

Settings:

{
  "workbench.iconTheme": "material-icon-theme",
  "workbench.colorTheme": "Dracula",
  "workbench.startupEditor": "newUntitledFile",
  "terminal.integrated.fontSize": 14,
  "terminal.integrated.shell.osx": "/bin/zsh",
  "editor.tabSize": 2,
  "editor.fontSize": 18,
  "editor.lineHeight": 24,
  "editor.fontFamily": "Fira Code",
  "editor.fontLigatures": true,
  "explorer.compactFolders": false,
  "editor.renderLineHighlight": "gutter",
  "workbench.editor.labelFormat": "short",
  "extensions.ignoreRecommendations": true,
  "javascript.updateImportsOnFileMove.enabled": "never",
  "breadcrumbs.enabled": true,
  "editor.parameterHints.enabled": false,
  "typescript.updateImportsOnFileMove.enabled": "never",
  "explorer.confirmDragAndDrop": false,
  "explorer.confirmDelete": false,
  "editor.rulers": [80, 120],
  "files.autoSave": "onFocusChange",
  "editor.formatOnPaste": true,
  "editor.formatOnSave": true,
  "editor.formatOnType": true,
  "workbench.preferredDarkColorTheme": "Dracula",
  "workbench.preferredHighContrastColorTheme": "Dracula",
  "workbench.preferredLightColorTheme": "Dracula",
  "eslint.alwaysShowStatus": true,
  "eslint.format.enable": true,
  "[jsonc]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "debug.extensionHost.useV3": true,
  "[javascript]": {
    "editor.codeActionsOnSave": {
      "source.organizeImports": true,
      "source.fixAll.eslint": true,
    }
  },
  "[javascriptreact]": {
    "editor.codeActionsOnSave": {
      "source.organizeImports": true,
      "source.fixAll.eslint": true,
    }
  },
  "[typescript]":{
    "editor.codeActionsOnSave": {
      "source.organizeImports": true,
      "source.fixAll.eslint": true,
    }
  },
  "[typescriptreact]":{
    "editor.codeActionsOnSave": {
      "source.organizeImports": true,
      "source.fixAll.eslint": true,
    }
  }
}

Version: 1.44.0 Commit: 2aae1f26c72891c399f860409176fe435a154b13 Date: 2020-04-08T11:22:13.689Z Electron: 7.1.11 Chrome: 78.0.3904.130 Node.js: 12.8.1 V8: 7.8.279.23-electron.0 OS: Linux x64 4.15.0-30deepin-generic

misaku commented 4 years ago

bugLocalHistory.gif

dkolba commented 4 years ago

@misaku I had the same problem when invoking VSCode via cli on individual files. But if you open a folder (workspace), local-history starts working as expected.

misaku commented 4 years ago

@misaku I had the same problem when invoking VSCode via cli on individual files. But if you open a folder (workspace), local-history starts working as expected.

but in my case is a folder worksapce =(

bsutton commented 3 years ago

I"m having the same problem. localhistory version 1.81.

Version: 1.52.1 Commit: ea3859d4ba2f3e577a159bc91e3074c5d85c0523 Date: 2020-12-16T16:32:10.090Z Electron: 9.3.5 Chrome: 83.0.4103.122 Node.js: 12.14.1 V8: 8.3.110.13-electron.0 OS: Linux x64 5.8.0-33-generic snap

settings.json "local-history.exclude": [

    "**/.history/**",
    "**/.vscode/**",
    "**/node_modules/**",
    "**/typings/**",
    "**/out/**",
    "**/Code/User/**"
],
"local-history.treeLocation": "localHistory",
"local-history.path": "./",

I'm opening a workspace. I've tried setting the local.path to .\ but this appeared to make no difference. I've checked the vscode logs an I don't see any errors.

I'm using the dart-code extension if that's important.

I've tried uninstalling/restart vscode/re-install to no affect.

There is a .history in each project folder as well as the workspace. I suspect this is because occasionally I've opened individual folders directly. The workspace level .history folder structure seems to be populated but no files. I've just tried deleting all of the .history folders and restarted vscode. When I edit a file the .history folder isn't being recreated.

Is there any way to diagnose the problem?

mcamou commented 3 years ago

I am having the same problem, I have the same configuration as @bsutton. How can we diagnose this?

fabienmoritz commented 3 years ago

Same issue with a snap version of VS Code on Ubuntu 20.04.

I tried disabling other extensions, installing previous versions of this extension with no effect. It used to work, I didn't notice at first when it stopped doing so. There are no errors in the VS Code logs.

I tried tweaking the options with no effect. When I modify a file, its path is created in the .history folder, but not the file itself. Quite distressing.

mzietlow commented 3 years ago

I seem to be experiencing the same issue with VS Code 1.53.2 running on Ubuntu 20.04

fractalvision commented 3 years ago

Same here. Doesn't work at all, the history is always empty. Tried to reinstall, restart VSCode, nothing helps. Mint 20. VSCode info: Version: 1.55.1 Commit: 08a217c4d27a02a5bcde898fd7981bda5b49391b Date: 2021-04-07T15:01:24.315Z Electron: 11.3.0 Chrome: 87.0.4280.141 Node.js: 12.18.3 V8: 8.7.220.31-electron.0 OS: Linux x64 5.4.0-70-generic

fabienmoritz commented 3 years ago

I did a short debug session. The history file is successfully created here https://github.com/zabel-xyz/local-history/blob/0543d2d06645e3434e4372b45f53a5dc80eb1f00/src/history.controller.ts#L255, but is deleted just after. Does it inspire you something ? I fear a race condition. Any idea of a culprit ?

BLaDZer commented 3 years ago

@zabel-xyz I found out that the history is deleted after the specified seconds in the settings local-history.saveDelay. Sounds crazy but it is. For OP it is 0 seconds so...

VSCode:

Version: 1.56.2 Commit: 054a9295330880ed74ceaedda236253b4f39a335 Date: 2021-05-12T16:45:26.313Z Electron: 12.0.4 Chrome: 89.0.4389.114 Node.js: 14.16.0 V8: 8.9.255.24-electron.0 OS: Linux x64 5.4.0-72-generic

edit: after some extension debugging I found that bug is happening here https://github.com/zabel-xyz/local-history/blob/0543d2d06645e3434e4372b45f53a5dc80eb1f00/src/history.controller.ts#L508 because

Birth time is the time when the file was created on the filesystem, also known as the file creation time (crtime on EXTFS). Note that, this is not defined by POSIX; only last access time (atime), last modification time (mtime) and the inode change time (ctime) are mandated by POSIX.

https://askubuntu.com/a/918303

birthtime "Birth Time": Time of file creation. Set once when the file is created. On filesystems where birthtime is not available, this field may instead hold either the ctime or 1970-01-01T00:00Z (ie, Unix epoch timestamp 0). This value may be greater than atime or mtime in this case. On Darwin and other FreeBSD variants, also set if the atime is explicitly set to an earlier value than the current birthtime using the utimes(2) system call.

https://nodejs.org/api/fs.html#fs_stat_time_values

so stat on some OS/FS may return empty "birthtime" for files

$ stat LICENSE_20210601115448 
  File: LICENSE_20210601115448
  Size: 1074        Blocks: 24         IO Block: 4096   regular file
Device: 35h/53d Inode: 3176940     Links: 1
Access: (0664/-rw-rw-r--)  Uid: ( 1000/    blad)   Gid: ( 1000/    blad)
Access: 2021-06-01 11:55:13.550508179 +0400
Modify: 2021-06-01 11:55:13.554508158 +0400
Change: 2021-06-01 11:55:13.554508158 +0400
 Birth: -
SpyPower commented 2 years ago

Hi, I am also experiencing the same behavior. Can we move forward with the PR? Thank you in advance! Cheers :D