Basically I want to know how you can know which file the user is editing? I’m guessing it has something to do with File Handlers but the docs aren’t very helpful on how to use them
Yeah I don’t think there is documented API for that.
You can use the fs
module to watch every file using fs.watchFile()
to listen for any changes to the file, which you can find the file that is being edited based on the file activity.
And until recently, you could also use the layout
module and using layout.findPaneByType()
to find any file tabs, though it has since been deprecated.
In the future, the new rui
module could be used to find the file that is being edited by the user more easily.
As far as I know, rui
is going to be used to expose Replit’s UI library.
I’m not too sure, @ArnavBansal if you could explain further please
Hey, we now have a session
API which lets you do this: https://docs.replit.com/extensions/api/session
There’s also a corresponding react hook: https://docs.replit.com/extensions/hooks/useActiveFile
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.