I have now done some more testing. First of all, here is code that illustrates the issue, to be put in Packages/User/foo.py:
import sublime, sublime_plugin
class FooCommand(sublime_plugin.WindowCommand):
def run(self):
v = self.window.new_file()
edit = v.begin_edit()
pt1 = 0
# Example comment to see how it looks like
pt2 = pt1 + v.insert(edit, pt1, "This is a comment\n")
pt3 = pt2 + v.insert(edit, pt2, "This is a string\n")
v.add_regions('foo_comment', [sublime.Region(pt1, pt2)], 'comment')
v.add_regions('foo_string', [sublime.Region(pt2, pt3)], 'string')
v.end_edit(edit)
Now look at the colors used in the line âExample comment to see how it looks likeâ and also look at the colors of âThis is a stringâ.
Open the console and type âwindow.run_command(âfooâ, {})â into it.
The result will be a new view with two lines in it. I expect the first line to have the same colors as the example comment, and the second line to have the same colors as âThis is a stringâ in the foo.py file.
But with the default theme, I get two lines with background and foreground colors swapped: In foo.py, the comment has a grayish foreground color, in the new view the comment has a grayish background color. And in foo.py, the strings have a yellowish foreground color, but in the new view the string has a grayish background color.
Using the Soda Light theme along with the Espresso Soda syntax highlighting, the comment line has swapped background/foreground colors, but the string line looks correct.
Using build 2154.