Skip to content

Navigation Menu

Sign in
Sign up

How top programmatically open files? #1158

Unanswered
treagod asked this question in Q&A
Dec 14, 2021 · 2 comments · 3 replies
Discussion options

Hi I'm trying to add a fuzzy search (see my branch here) and the concept is really working well for now.

I'm now at the point where I want to open a file which was selected by the fuzzy finder (see plugins/fuzzy-search/fuzzy-search.vala line 80). But open_file from the interface can't open the file because it says the file is corrupt (it isn't!).
If the selected file is already open the editor will crash.

Can somebody guide me here how to programmatically open a file from a plugin? I'm kind of lost.

I'm getting following segmentation fault when opening the file:
open_file_error

You must be logged in to vote

Replies: 2 comments 3 replies

Comment options

Plugins have access to the MainWindow so you could try creating a Services.Document from the file and then call the open_document function.

You must be logged in to vote
2 replies
Comment options

Thanks for the quick reply.

I tried it, but I'm still getting the same error:
editor_error_window

As far as I can tell the plugin interface method open_file is doing this internally.

Comment options

Looks like you have a null file?

Comment options

If you make and submit a draft PR it will be easier to investigate.

You must be logged in to vote
1 reply
Comment options

Created #1159

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants

AltStyle によって変換されたページ (->オリジナル) /