本文整理汇总了Python中sublime.View.buffer_id方法的典型用法代码示例。如果您正苦于以下问题:Python View.buffer_id方法的具体用法?Python View.buffer_id怎么用?Python View.buffer_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sublime.View
的用法示例。
在下文中一共展示了View.buffer_id方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: notify_did_change
# 需要导入模块: from sublime import View [as 别名]
# 或者: from sublime.View import buffer_id [as 别名]
def notify_did_change(view: sublime.View):
file_name = view.file_name()
window = view.window()
if window and file_name:
if view.buffer_id() in pending_buffer_changes:
del pending_buffer_changes[view.buffer_id()]
config = config_for_scope(view)
client = client_for_view(view)
if client and config:
uri = filename_to_uri(file_name)
languageId = config.get_language_id(view)
ds = get_document_state(window, file_name)
if ds.languageId == languageId:
params = {
"textDocument": {
"uri": uri,
"version": ds.inc_version(),
},
"contentChanges": [{
"text": view.substr(sublime.Region(0, view.size()))
}]
}
client.send_notification(Notification.didChange(params))
else:
# The languageId has changed, reopen file
ds.languageId = languageId
params = {"textDocument": {"uri": uri}}
client.send_notification(Notification.didClose(params))
params = {
"textDocument": {
"uri": uri,
"languageId": ds.languageId,
"text": view.substr(sublime.Region(0, view.size())),
"version": ds.inc_version(),
}
}
client.send_notification(Notification.didOpen(params))
示例2: queue_did_change
# 需要导入模块: from sublime import View [as 别名]
# 或者: from sublime.View import buffer_id [as 别名]
def queue_did_change(view: sublime.View):
buffer_id = view.buffer_id()
buffer_version = 1
pending_buffer = None
if buffer_id in pending_buffer_changes:
pending_buffer = pending_buffer_changes[buffer_id]
buffer_version = pending_buffer["version"] + 1
pending_buffer["version"] = buffer_version
else:
pending_buffer_changes[buffer_id] = {
"view": view,
"version": buffer_version
}
sublime.set_timeout_async(
lambda: purge_did_change(buffer_id, buffer_version), 500)
示例3: update_diagnostics_phantoms
# 需要导入模块: from sublime import View [as 别名]
# 或者: from sublime.View import buffer_id [as 别名]
def update_diagnostics_phantoms(view: sublime.View, diagnostics: 'List[Diagnostic]'):
global phantom_sets_by_buffer
buffer_id = view.buffer_id()
if not settings.show_diagnostics_phantoms or view.is_dirty():
phantoms = None
else:
phantoms = list(
create_phantom(view, diagnostic) for diagnostic in diagnostics)
if phantoms:
phantom_set = phantom_sets_by_buffer.get(buffer_id)
if not phantom_set:
phantom_set = sublime.PhantomSet(view, "code_intel_diagnostics")
phantom_sets_by_buffer[buffer_id] = phantom_set
phantom_set.update(phantoms)
else:
phantom_sets_by_buffer.pop(buffer_id, None)