imbric
imbric

Reputation: 144

Unexpected highlighting in Sublime Text 3

I've been using Sublime for quite some time. I haven't done much customization, especially recently, however its highlighting lines of Ruby in a way I've never seen before. I don't know where it came from or why its being highlighted.

Retyping the contents of a file into a new buffer and resaving does not solve the issue, the highlighting appears in the new file as well.

Has anyone seen this or have any pointers as to why its happening?

enter image description here

Full File Contents

require 'serialport'

port_str = '/dev/tty.usbmodemfd121'
baud_rate = 9600
data_bits = 8
stop_bits = 1
parity = SerialPort::None

sp = SerialPort.new(port_str, baud_rate, data_bits, stop_bits, parity)

while true do
  sp.puts 123
end

sp.close

Sublime Settings:

{
"alignment_chars":
[
    "="
],
"alignment_space_chars":
[
    "="
],
"font_size": 15.0,
"ignored_packages":
[
    "LiveReload",
    "Git",
    "_User",
    "SublimeLinter",
    "BracketHighlighter",
    "Rubocop"

],
"scroll_past_end": true
}

Ruby Specific Settings

{
  // The number of spaces a tab is considered equal to
  "tab_size": 2,

  // Set to true to insert spaces when tab is pressed
  "translate_tabs_to_spaces": true,

  // If translate_tabs_to_spaces is true, use_tab_stops will make tab and
  // backspace insert/delete up to the next tabstop
  "use_tab_stops": true,
}

Package Control Settings

{
"auto_upgrade_last_run": null,
"installed_packages":
[
    "AdvancedNewFile",
    "Alignment",
    "Better CoffeeScript",
    "BracketHighlighter",
    "CoffeeComplete Plus (Autocompletion)",
    "CoffeeScript",
    "DocBlockr",
    "Emmet",
    "Gist",
    "Git",
    "IndentGuides",
    "LiveReload",
    "Nettuts+ Fetch",
    "Package Control",
    "PhpBeautifier",
    "PlainTasks",
    "RSpec (snippets and syntax)",
    "RuboCop",
    "SCSS",
    "SublimeLinter",
    "Todo",
    "Wordpress"
]
}

Update: I think the issue is due to the RuboCop package. But its a little more complicated than that.

Currently Rubocop is enabled, I see highlighting and clicking on a highlighted line displays the offense in the bottom status bar as seen here.

enter image description here

However after disabling the Rubocop package and restarting Sublime there is still highlighting as shown here. The lst shown at the top is the result from Sublime's "Package Control: Enable Package" command which means its showing the currently disabled package. Also, clicking on the highlighted line does not report the offense in the bottom status bar as before.

enter image description here

I'm feeling confident that the issue is the Rubocop package though I don't really have a diagnosis. I'm happy to close this question if necessary.

Upvotes: 2

Views: 1550

Answers (2)

Patrick
Patrick

Reputation: 160

It was indeed an issue related to the Sublime RuboCop plugin.

The main error was, that the marks became invalid after restarting ST. Thanks @imbric for reporting it!

I fixed that today - if you update the plugin via Package Control, the unexpected marks should behave as expected.

You can turn off the marks via the ST menu entry "RuboCop: Toggle auto check".

Upvotes: 2

MattDMo
MattDMo

Reputation: 102892

Part of the problem is also BracketHighlighter. I don't know Ruby that well, so I'm not sure why it's happening, but I get the following with BracketHighlighter (and a ton of other plugins) enabled:

BracketHighlighter enabled

When I disable BracketHighlighter, the question mark disappears, as does the box around the while. Try disabling BracketHighlighter, and see if your highlighting goes away.

Also, when I delete the word do, the box disappears, so it may just be a Ruby syntax error.

Upvotes: 0

Related Questions