Unexpected highlighting in Sublime Text 3 - ruby

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?
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.
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.
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.

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".

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:
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.

Related

Hide inline errors (phantoms) in Sublime Text 4

The following used to work in Sublime Text 3, but gives an error in ST4.
{
"keys": ["f10"],
"command": "exec",
"args": {"hide_phantoms_only" : true },
},
Error message: __init__() got an unexpected keyword argument 'hide_phantoms_only'.
Similar to my previous question here How to hide Sublime inline errors (phantoms) with Escape, but the solution no longer works in Sublime Text 4.
That’s because in ST4, phantoms are no longer used to show build errors. They have been replaced by something called region annotations.
Sublime Text 3: Uses Inline phantoms
Sublime Text 4: Uses the so called region annotations, that appears on the far right edge of the view. This was done mainly to reduce reflow of the document (since phantoms can cause text to shift around, which results in a somewhat janky experience).
Error message: init() got an unexpected keyword argument 'hide_phantoms_only'
Coming back to this, since phantoms are no longer used in ST4 to show build errors, any phantom related arguments that the exec command used to take is also no longer valid. Hence, the error.
Currently, I don’t think there is a way to have a key binding that will close all the error annotations, though there is an open feature request to make annotations more key board friendly (& closing all annotations is a part of that issue)
https://github.com/sublimehq/sublime_text/issues/3422

Copy in insert mode with mouse

I'm using vsvim, sometimes I highlight code in insert mode with my mouse and want to copy or cut it out. But I don't know-how. Instead, I have to change back to normal mode, highlight it again then cut it. I tried to Ctrl+O but it would get rid of the highlight. Does anyone know how to solve this?
highlighted text in insert mode
I have not used this extension, but when running vim natively, if you highlight stuff in insert mode, you can right-click and click on copy. Not sure whether this works in Visual Studio. However, reading the docs in GitHub I see there is a vim.handleKeys setting, that you can set in settings.json and you could specify C-c and C-v to be false in order to support Ctrl+c and Ctrl+v natively. The doc provides this example:
"vim.handleKeys": { "<C-f>": false }
which in your case would look like this:
"vim.handleKeys": {
"<C-c>": false,
"<C-d>": false
}

Trailing Comma in "settings.json" in VSCode 1.48

I am a newbie in Vscode, I have started setting up the VScode editor for my Python learning. One thing that is bugging me is Trialing Comma Error in Problem. Could you please help me with this?
Thanks in advance.
enter image description here
Issue details
// Trims lines that contain only whitespace after pressing Enter on them.
"pythonIndent.trimLinesWithOnlyWhitespace": false,
// After creating a hanging indent, press tab to leave the indented section and go to the ending bracket.
"pythonIndent.useTabOnHangingIndent": false
}
,
]
a settings.json file is a dictionary with keys. No array of dictionaries.
the simplest settings.json file with 3 keys
{
"editor.tabSize": 2,
"editor.detectIndentation": false,
"workbench.activityBar.visible": true
}
This is an actual issue: Github Issues site
I am getting the same error. Note as per comments his settings file is NOT 4k lines, this is the "combined" settings file created by VS Code. My actual settings.json file (Win10 location: C:\Users<username>\AppData\Roaming\Code\User\settings.json) is 52 lines, but the file shown by Code with the error is about 3900 lines (Im guessing combined from various sources which I have yet to track down). Will update when fix found - currently some back and forth in the thread (see link).

Can't close Visual Studio Code Window with my shortcut, yet it works for tabs

In apps I use, I like to use the command ctrl+cmd+left to close tabs and to close windows when there are no open tabs.
I tried to do the same for Visual Studio Code by searching for the commands with cmd+w and replacing them in my keybindings.json file with ctrl+cmd+left.
Those are the first two elements in my keybindings.json below.
// Place your key bindings in this file to overwrite the defaults
[
{ "key": "ctrl+cmd+left", "command": "workbench.action.closeWindow",
"when": "!editorIsOpen" },
{ "key": "ctrl+cmd+left", "command": "workbench.action.closeActiveEditor" },
{ "key": "ctrl+cmd+right", "command": "workbench.action.files.newUntitledFile" }
]
I can close tabs with ctrl+cmd+left. I think that means the 2nd command is working. The 3rd one above for opening tabs with ctrl+cmd+right works too.
However I cannot close the window with ctrl+cmd+left, which I'm pretty sure means that the first command isn't working. Yet, I can still close the window with cmd+w.
Why can't I close a window with no tabs open with ctrl+cmd+left? Why does it still work for cmd+w?
EDIT: I was able to get things to work as I wanted by changing the order of the first two shortcuts. I haven't figured out why that works yet and would appreciate it if someone could answer that. I suspect there's some sort of cascading esque feature that causes the 2nd command to overwrite the first command and the when condition prevented that from happening with the order reversed.
Keybinding rules in Visual Studio Code are evaluated from the bottom to the top. So it starts with your custom rules in your keybindings.json file and goes through the default rules. The first keybinding rule that matches your key and meets its when condition is applied. See the VSCode docs
As a result, when I tried to close a window it would always match the keybinding to close an active window. Switching the order of the first two commands above resolves the problem because now when I try to close a window it matches the when condition of the editor is not open. Additionally, when I'm trying to close a tab it doesn't match the condition of the editor is not open so it looks up to the next rule (which has no when condition limiting the scope of the rule) and closes the active editor.
So Visual Studio Code actually "cascades" from bottom to top.

Sublime text find in selection

When I select multiple lines of text in text editor Sublime Text 3, and try to find (Ctrl+F) an existing string in it, it fails. In fact, any highlighting I do somehow makes the string unfindable. For example, if I highlight all text in my file, and Ctrl+F an existing string, it is unable to find any matches. Only when the string I want to find is not highlighted can the string be searched.
I have the 'in selection', 'highlight matches', and 'wrap' flags on when highlighting. My user preferences are as follows:
{
"color_scheme": "Packages/Color Scheme - Default/Monokai.tmTheme",
"font_size": 10,
"auto_find_in_selection": true,
"trim_trailing_white_space_on_save": true,
"ignored_packages":
[
"Vintage"
]
}
Any help will be appreciated. I have been trying to figure this out for an hour. Originally I had "auto_find_in_selection" set to false - I thought that was the culprit, but the problem persisted even after setting it to true.
go to settings-> user and add this line:
"find_selected_text": true
next time you select a text and press cmd+'f' it will be there as default search.
I had been fighting with this problem as well and for now (ST3 Build 3059) it still seems to be a bug. It seems like that the editor is not updating the selection for the search/replace bar while you have it open.
Here's a workaround:
1) Close the find/replace bar
2) Make your selection
3) Open search/replace bar and enter your search query
Hope this helps!

Resources