Sublime Forum

Weird behavior with window.open_file() and syntax detection for e.g. C++ files

#1

Im doing some plugin development (mostly for fun). I have a plugin that calls

self.view.window().open_file(filename+":"+lineNo, sublime.ENCODED_POSITION)
self.view.window().open_file(filename)

and in both cases it opens some filetypes with plain text syntax. If I open these files through the menu bar (file->open file) it detects the syntax as expected.

So far I’ve seen this with hpp/cpp files and yaml files. It works like expected with .py and .sh files though. Can anyone provide some insight into why I might be seing this behavior ? or maybe how to avoid it ?

Much appreciated,

  • JW
0 Likes

#2

As always the problem reveals itself after making a post about it :slightly_smiling:
The issue was with the filename that contained a trailing space. Unfortunately I hadnt noticed this since it opens the file anyway. I guess the reason it worked for some filetypes is due to better syntax detection ?

0 Likes