Peter Steiwer · Apr 9, 2021

VSCode "Go To Definition" opens in Read Only mode

As the title says, when I use the "Go To Definition (F12)" option, it opens the definition in read only mode. Is there some way to either directly make the go to option editable or can i turn the read only version into an editable version? I end up needing to open the file directly and then manually going to the method definition myself.

0 373
Discussion (10)3
Log in or sign up to continue

The issue is probably in export settings, which used to find a real file for resources on server. You can check it by opening ObjectScript Explorer, when you dive to your classes/routines, it should show an icon next to the name, the same as in File Explorer. So, it's mean that it's linked correctly. If not. you have to look at "objectscript.export" settings, you may find some useful info about this here.

Another possible issue is that it comes from the Language Server, you may temporarily disable that extension if it's installed and active to see if it's changed (reload is required). And if the issue disappears I would suggest installing the latest beta version of Language Server. And fill the issue in the repo, if it's still happens.

I looked into these suggestions, but I still can't make it work. I see that when I am editing a file and I hover over the name on the tab at the top, it says "C:\Users\....\PivotSubscriptions\Subscription.cls". After using "Go To Definition", the new class opens with the path of "/PivotSubscriptions/EventLog.cls"

Sounds like you are using the client-side editing paradigm. As Dmitry says, unless you haven't installed Language Server it will be LS that initially handles your "Go to Definition" request. But I think LS then calls an API entrypoint named serverDocumentUriForUri in the main ObjectScript extension (OS) to find out where the target document should be fetched from. As the API name indicates, this returns a uri (a document reference) that always fetches code from the server. And since you are using the client-side editing paradigm the fetched code cannot be edited.

Please open an issue on the repo at where it can be tracked and managed better than in this DC post.

I think John is basically correct, but I don't see this as an issue.  When you are doing client-side editing, which is what I normally do, you need to export code to your project to edit it.  This is an action you need to perform as every definition you look at should not necessarily become part of your project.  When you choose to 'Go To Definition' the InterSystems extension looks to see if it's local and opens that if it is, local meaning client-side.  If not it opens it from the server which is always read-only when working in client-side editing.  To edit export it then open the local copy.

When using 1.1.6 and 1.0.11, I am still getting a read only copy when I use Go to Definition. Are there any settings that need to be configured in a specific way?

Do you have the file exported to your local file system already? If not, then you'll have to set the serverSideEditing setting to true for the server copy that gets opened to be editable.

Yes, the second class is in the same project as the first and both exist locally on the file system

This now works after modifying my objectscript.export "folder" setting. It was previously "src" and is now "".