vscode icon indicating copy to clipboard operation
vscode copied to clipboard

TM_FILENAME_BASE generates the old filename ( just for uppercase and lowercase changes)

Open sajadko opened this issue 3 years ago • 1 comments

Does this issue occur when all extensions are disabled?: Yes

  • VS Code Version: 1.71.2
  • OS Version: Windows 11 Pro 21H2 22000.978

Steps to Reproduce:

  1. Create a user snippet for JS file ( i tested just with js files ) and use TM_FILENAME_BASE variable in it .
  2. Create a new js file and start editing that file ( just write some lines of code )
  3. Rename the js file ( just change the uppercase or lowercase of the old name, for e.g. change reactcomponent.js to Reactcomponent.js )
  4. Now use that snippet in the file, the old name has been generated instead of the new name.

this occurs just for changing uppercase or lowercase in the file name. if you change the name into a new one ( for e.g. just add a letter) the new name will be generated successfully ,

sajadko avatar Sep 21 '22 11:09 sajadko

this occurs just for changing uppercase or lowercase in the file name.

On windows and mac (which default to being case-insensitive) we don't treat this as a "true" rename, eg the associated uris don't change but it is merely a label change. That new label isn't propagated into all areas

jrieken avatar Sep 21 '22 12:09 jrieken

@bpasero Is there a way to get the UI path, esp. given this happens in the editor/monaco-layer. Also, I am using the label service so kinda surprised that this doesn't Just Work ™️

jrieken avatar Dec 05 '22 15:12 jrieken

@jrieken not on the editor layer so far, what we typically end up doing in the workbench is ask the editor for its preferred resource:

https://github.com/microsoft/vscode/blob/7af646716e9889ec1736e231cf3f3f037f5b2dbd/src/vs/workbench/common/editor.ts#L784-L788

It is then being used by the EditorResourceAccessor utility by calling getOriginalUri:

https://github.com/microsoft/vscode/blob/7af646716e9889ec1736e231cf3f3f037f5b2dbd/src/vs/workbench/common/editor.ts#L1152-L1168

Where is your code for using the label service?

bpasero avatar Dec 05 '22 18:12 bpasero

Where is your code for using the label service?

This is where I use it https://github.com/microsoft/vscode/blob/86127c6cce7f27b71b8b112d0c59cc6ab6d5f4ad/src/vs/editor/contrib/snippet/browser/snippetVariables.ts#L185

jrieken avatar Dec 06 '22 08:12 jrieken

Yeah, and that is the canonical URI of the model. The label service is not aware of the original URI, lets discuss.

bpasero avatar Dec 06 '22 08:12 bpasero

@sajadko This issue is acknowledged but nevertheless I am going to close it as wont-fix. This is because the fix-costs are quite high. When using a case-insensitive file system all casings are correct (in the terms of resolving to the correct file) and the knowledge what "label path" is currently preferred isn't available to the snippets feature layer.

jrieken avatar Dec 12 '22 14:12 jrieken