Sublime Forum

Syntax setting works differently for regular views and output panels

#1

Problem description

This code works for a regular view and immediately effects a change of syntax.

view.settings().set('syntax', 'Correct/Path/To/Syntax/File')

However, the same seems to not be true for output panels. The line above has no effect, and only View.set_syntax_file() seems to work with output panels.

The following code runs right after a new output panel has been created.

    def configure(self):
        assert self.configuration, 'valid configuration required'

        # default config
        self.set('word_wrap', False) # .set does self.view.settings().set()
        self.set('line_numbers', False)
        self.set('gutter', False)
        self.set('scroll_past_end', False)

        for name, value in self.configuration.settings:
            self.set(name, value)
            # If we don't do this, the syntax change does not seem to take effect,
            # even though the syntax property is set.
            if name == 'syntax':
                self.panel.set_syntax_file(value)

The workaround works, but if I remove it, the syntax is never applied, even though view.settings().get('syntax') returns the correct path. I’ve obtained the configured output panel via Window.find_output_panel().

Expected behavior

View.settings().set('syntax', path) should work equally for regular views and output panels, effecting an immediate change of syntax.


Editor info (as provided by Sublime Text API)

General details about Sublime Text

Version and architecture

name: Sublime Text
version: 3125
architecture: x64
channel: dev
platform: windows

Package data

omitted

View settings

syntax: Packages/Python/Python.sublime-syntax
tab_size: 4
translate_tabs_to_spaces: True
encoding: UTF-8
em width: 7.0
selection count: 1
has non empty selections: True

View state

is view dirty: False
is view readonly: False

Profiling data (as reported by Default/profile.py)
on_activated:
    Vim.commands.event_sync_mode: 0.084s total, mean: 0.001s, max: 0.003s
    Default.pane: 0.000s total, mean: 0.000s, max: 0.000s

on_close:
    Default.pane: 0.018s total, mean: 0.000s, max: 0.005s
    Default.settings: 0.001s total, mean: 0.000s, max: 0.001s

on_deactivated:
    Vim.commands.event_sync_mode: 0.004s total, mean: 0.000s, max: 0.001s
    Default.history_list: 0.006s total, mean: 0.000s, max: 0.001s

on_hover:
    Default.symbol: 0.000s total, mean: 0.000s, max: 0.000s

on_load:
    Default.detect_indentation: 0.022s total, mean: 0.001s, max: 0.002s
    Default.exec: 0.000s total, mean: 0.000s, max: 0.000s

on_modified:
    Default.settings: 0.011s total, mean: 0.000s, max: 0.001s

on_pre_close:
    Default.history_list: 0.008s total, mean: 0.000s, max: 0.001s
    Default.settings: 0.000s total, mean: 0.000s, max: 0.000s

Platform info (as provided by wmic.exe)

Details about the current platform

OS information

OSArchitecture: 64-bit
Version: 10.0.14393
BuildNumber: 14393
BuildType: Multiprocessor Free
Caption: Microsoft Windows 10 Pro
FreePhysicalMemory: 10373856
FreeSpaceInPagingFiles: 2490368
FreeVirtualMemory: 12122440

Display information

PixelsPerXLogicalInch: 96
PixelsPerYLogicalInch: 96


This report was generated by the Troubleshooting package.

0 Likes

#2

I think the way settings work on output panels is dodgy. You have to call create_output_panel again for the settings to be applied. We can see this from the Packages/Default/exec.py file:

    # Call create_output_panel a second time after assigning the above
    # settings, so that it'll be picked up as a result buffer
    self.window.create_output_panel("exec")
2 Likes

#3

I thought that was only required for result_*-type settings, but it makes sense. Thanks!

0 Likes

#4

Also, afaik using the method to set the syntax is preferred because it’s more flexible, but I don’t have a source on this.

0 Likes