psi-header icon indicating copy to clipboard operation
psi-header copied to clipboard

Changes-tracking doesn't work on SSH remote

Open diverger opened this issue 1 year ago • 10 comments

Hi,

It seems the changes-tracking function won't work when installed on a SSH remote.

diverger avatar Jan 07 '25 14:01 diverger

Could you share your config? Does the same config work locally?

D

davidquinn avatar Jan 08 '25 20:01 davidquinn

Happened to me inside a Docker container. My config is:

"psi-header.changes-tracking": {
	"enforceHeader": true,
	"autoHeader": "autoSave",
	"exclude": [
		"*"
	],
	"include": [
		"cpp",
		"shellscript",
		"dockerfile",
		"cmake"
	]
}

Tried with and without "exclude".

ferreteleco avatar Jan 09 '25 18:01 ferreteleco

You have not set isActive to true

davidquinn avatar Jan 09 '25 20:01 davidquinn

Could you share your config? Does the same config work locally?

D

Yes, the same configuration work on local machine. I copied the 'user' configuration to the 'remote' page in the extension settings. The settings for changes tracking is

  "psi-header.changes-tracking": {  
    "isActive": true,
    "replace": [
      "Copyright",
      "\\file"
    ],
    "ignoreLines": []
  }

diverger avatar Jan 10 '25 02:01 diverger

Yes, the same configuration work on local machine. I copied the 'user' configuration to the 'remote' page in the extension settings. The settings for changes tracking is

Sorry, but I cannot see anything obviously wrong. I have been through the MS documentation and cannot see anything obvious as to why it would not work. I don't have a remote environment that I can do testing on, but as this is the first time I have had a report of a problem working via remote I have to assume that it might have something to do with your VSCode setup on the remote machine. Are you able to get anything from the remote machine that might indicate the source of a problem?

Regards D

davidquinn avatar Jan 15 '25 08:01 davidquinn

Hi,

I tried it again. Without changing anything, it works now :). Don't know why, and thanks for your help.

diverger avatar Jan 15 '25 09:01 diverger

Thanks for letting me know and glad it works.

D

davidquinn avatar Jan 15 '25 11:01 davidquinn

Hi,

I'm back again. I find another strange thing. The tacking works well for my '.c' file on SSH Linux remote. But failed with .dts files (Linux device tree file). I suspect that it's the Linux system or other extensions are prevent the tracking functions working. It may be not the problem of psi, but any suggestions? Where can I get the extension log output?

And are there any methods to force it to update the filename and modified time?

Thanks.

diverger avatar Jan 16 '25 09:01 diverger

Hi, D

Finally I find the reason. My lang-config is as below:

    {
      "language": "*",
      "begin": "/*!",
      "prefix": " * ",
      "end": " */"
    },

You see, there is a ' ' in each line prefix. But my DTS file formatter extension formatted it and removed the ' ' in each line of the header. And it seems he psi extension will check the header format before tracking the changes. In my situation, it missed because the removed ' ' before each line.

May there an option to let changes-tracking function be independent of the header format? Such as give it's own matching rule?

Thanks.

diverger avatar Jan 16 '25 10:01 diverger

This has come up once before where a formatter extension modified the white space. Unfortunately there isn't a robust solution to this because the changes-tracking needs the language template in order to work out where the placeholders are that can be updated. Keep in mind that the extension does not force the header to be at the top of the file and also compact mode means it doesn't even have a cast iron "this is the start/end of the header". Also, as it currently works, the extension can deal with changes to the header made by the user manually after it was created. But all of this requires the changes tracking logic to know for sure that it is (a) in a header and (b) that it knows how to match lines in the header with the correct line in the template so it can get the placeholders from the template.

IIRC it was previously resolved by configuring the formatter to not alter comment blocks, alternatively, your only option is to not have leading spaces in the prefix setting (which is what your formatter currently wants to enforce).

But really, you are using a formatter that is enforcing a change in your header, so there is no point in trying to configure this extension to do something that is different to what the formatter will enforce.

Regards D

davidquinn avatar Jan 16 '25 13:01 davidquinn