Hide inline errors (phantoms) in Sublime Text 4 - sublimetext

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

Related

Sublime Text disable goto animation

When using the goto function to bring my cursor to a particular line number, say 3017, how do I prevent Sublime from jumping around from line to line until I hit enter?
For instance, in that case, I would jump to the following lines:
3
30
301
3017 (finally)
Sublime Text 3 seems to have two "Goto Line" features:
one which is built in via the "Goto Anything" overlay. Internally, the command to execute this is show_overlay with the arguments {"overlay": "goto", "text": ":"}. This is the default, available from the Goto menu -> Goto Line, and with keybinding Ctrl+G. MattDMo is correct in his answer that it is not possible to disable fuzzy matching in this overlay.
one which is included in the "Default" package as a plugin and shows a small prompt panel at the bottom of the screen. Internally, the command to execute this is prompt_goto_line, with no arguments necessary. This implementation has the behavior you desire, and will only go to the specified line when you hit the enter key. It has no default way of accessing it, but read on... :)
The reason I have mentioned the internal commands above is because Sublime Text makes it possible to add or override keybindings, and also to change or add menu items, and the commands are used to instruct Sublime Text what action to perform.
Therefore, this means that you can choose to override the existing menu item and/or keybinding, (and/or you can create a new menu item and/or keybinding) to use the prompt_goto_line command. The two links I have just provided should give enough detail on how to perform these tasks, but if you would like more specific information, please let me know in a comment and I will provide it.
This feature is by design, and cannot be disabled. Most popup menus in Sublime feature "fuzzy matching", meaning you do not need to type the full search term, just a few letters (for example, pci finds Package Control: Install Package in the Command Palette). The menus also feature instant searching, which is what you are seeing. This means that you do not need to hit Enter to search, just start typing and the matches appear as you type.

Sublime Text autocomplete suggestions looks corrupt, how to fix?

Not sure what is happening to my installation of Sublime Text, when ever autocomplete drop down appears it is populated with a bunch of corrupted looking suggestions, this just started recently. I have Googled around and have not yet seen another person with the same issue. I've already tried uninstalling, throwing out User/me/Library/Application Support/Sublime Text 3 folder, and re-installing, but still the corrupted text shows up in my autocomplete. I am working on a Macbook Air, I also use a Macbook Pro at work with the same setup and have never seen this happen before?
As established in the comments, you have base64-encoded strings (likely an inline image) elsewhere in your file. Sublime's default autocomplete populates its choices menu with elements from your file, and uses fuzzy matching to bring up selections. Since base64 can contain all letters and numbers, chances are that any sequence you're typing may match, and that string will be brought to the top of the autocomplete dropdown.
There are a couple of ways around this. First, if the base64 content is actually scoped as a string (i.e., it's surrounded by single or double quotes), you can add the following line to your settings (Preferences -> Settings-User):
"auto_complete_selector": "source - comment - string, meta.tag - punctuation.definition.tag.begin"
This should hopefully solve your problem for the time being, with the downside that you lose any other string-encoded information that you may wish to be in autocomplete.
You can also try using an autocomplete engine like SublimeCodeIntel (works for multiple languages, including JS) or TernJS. These can have the option of turning off Sublime's internal autocomplete mechanism, and just filling in the choices with their generated content.

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

mac automatically selecting text after delete

Running OS X 10.9, though the issue occurred in 10.8 as well, and I've noticed it in Xcode and Netbeans. When I highlight some text and delete it, usually some variable or string with in some code, the selected area stays selected, basically selecting the next set of characters. So when I continue typing, I type over that bit of selected code.
For example, say I have the following bit of code selected between the brackets:
The quick [brown fox] jumps over the lazy dog.
Now after I delete the text, the following text between the brackets will be selected:
The quick [ jumps ov]er the lazy dog.
The expected result would be to have no text selected and the cursor simply at the the 'J' (or space before) in the word jumps.
I've searched for this type of behavior in Netbeans and Xcode, but haven't found anything, so I'm concluding the behavior is with in OS X, but I haven't found anyone else with this issue nor how to remedy it.
Thank you for any help.
It´s an old issue, but still persists. This answer does not provide a solution but a recording of the issue happening in mail, which may help finding a reason. First you see a successful mark-and-overwrite, then a failing one. After that, I hit undo and redo several times, to show that the issue was recorded in the editing history. See the video in the following link:
https://www.dropbox.com/s/av3jtp7knhh8wki/Text_input_bug.mov?dl=0

Smart indent effect on completion (intelliSense) sessions

I am writing a Visual Studio extension which provides intelliSense for a certain content type.
The problem that I am facing now is the effect of "Auto Indent" that Visual Studio provides on empty lines when user types a character.
Here a completion session started on an empty line (over virtual spaces):
Notice the tab symbols on the other lines and no tab on the line with caret on it.
Now when use starts typing, VS automatically and correctly adds necessary tab characters to the line:
Now the problem is those Added tabs apparently become part of the user input and as a result CurrentSession.SelectedCompletionSet.SelectBestMatch() or Filter() method cannot find the current item which starts with "C" here (thinking user has typed \t\tC instead).
If I start the session on anywhere else which does not require auto indent everything works fine.
Any idea?
Edit (more information): I used a code flow very similar to:
Ook here
vsLua here
vsClojure here
In Lua and Clojure you wouldn't face this problem because they never provide intelliSense on virtual spaces (meaning they always start after a certain set of characters) and if you start after a character virtual spaces are already turned into real spaces.
Ook on the other had has the same problem.
Revised Answer:
Ah, I see. I interpreted your question thinking that you were referring to completion triggering via typing, not from the explicit command. If you enable "show whitespace" for the C# editor, you can see what we do here: when you trigger the "show completion" command, we explicitly realize the whitespace so you're no longer floating around in virtual space. You should probably do this as well. (Alternatively, you could detect the scenario and fix it up on the first typing by adjusting your ApplicableTo span, but that's probably not worth the trouble.)
You can get the whitespace that should be inserted from IEditorOperations. So MEF import an IEditorOperationsFactoryService, and then do:
var editorOperations = editorOperationsFactoryService.GetEditorOperations(textView);
var whitespace = editorOperations.GetWhitespaceForVirtualSpace(textView.Caret.Position.VirtualBufferPosition);
if (whitespace.Length != 0)
{
textView.TextBuffer.Insert(textView.Caret.Position.BufferPosition, whitespace);
}
(Funny aside: as I answered this, I was curious to see how we handled this in the Roslyn C# and VB editors. The answer was "not", but filtering still worked by pure luck later in the code.)
Original Answer:
I suspect by your description of the problem that you are implementing your completion like this: you know a character is about to be typed (either via a keyboard filter or IOleCommandTarget) and you trigger an ICompletionSession, where the tracking span is an empty span on the current caret position.
The best approach to fixing this is to not trigger the session before the key is pressed and goes into the editor, but rather after it. This is what we do in the Roslyn implementation for C# and VB completion. Then, when you are in your AugmentCompletionSession call and creating your CompletionSet, compute the "applicable to" span which consists of the non-whitespace characters around your caret. The easiest way to compute this might just be to call GetWordExtent from the text structure navigator.
This allows for other scenarios to work right. Consider scenarios where the user types C, presses escape, and then continues to type your identifier. If you want to trigger completion again, you'd have to do the math to ensure that the "C" is counted as part of your span anyways.

Resources