Sublime Forum

Inconsistent Sublime Phantoms Behavior


While developing a sublime plugin, I have noticed inconsistent behavior with phantoms that exist on the last line of a file when using LAYOUT_INLINE.

On the last line of the file, the cursor can move beyond the end of the file appearing after the comment. On any line that is not the last line of the file, cursor position is correctly handled.

I have created a sample plugin (see below) that demonstrates this behavior:

import sublime
import sublime_plugin

views = {}

class Listeners(sublime_plugin.EventListener):
    def on_activated(self, view):
    	if not in views:
    		views[] = sublime.PhantomSet(view)

    	phantoms = []

    	lines = view.split_by_newlines(sublime.Region(0, view.size()))
    	for line in range(0, len(lines)):
    		region = view.line(view.text_point(line, 0))
    		phantoms.append(sublime.Phantom(sublime.Region(view.line(region).b, view.line(region).b), '<span style="padding-left: 20px; color: var(--bluish)">MESSAGE</span>', sublime.LAYOUT_INLINE))

    	def callback():

    	sublime.set_timeout(callback, 1)

    def on_deactivated(self, view):
    	if in views: