Skip to content

Commit

Permalink
Merge branch 'master' of github.com:niosus/EasyClangComplete
Browse files Browse the repository at this point in the history
  • Loading branch information
niosus committed Feb 6, 2018
2 parents 5e25e11 + 1ad9a21 commit a19ecdd
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion plugin/popups/popups.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import sublime
import mdpopups
import markupsafe
import logging

from ..utils.macro_parser import MacroParser
Expand Down Expand Up @@ -146,7 +147,7 @@ def info(cursor, cindex, settings):
declaration_text += " const"
# Save declaration text.
popup.__text = DECLARATION_TEMPLATE.format(
type_declaration=declaration_text)
type_declaration=markupsafe.escape(declaration_text))
# Doxygen comments
if cursor.brief_comment:
popup.__text += BRIEF_DOC_TEMPLATE.format(
Expand All @@ -167,6 +168,7 @@ def info(cursor, cindex, settings):
# Show type declaration
if settings.show_type_body and is_type and cursor.extent:
body = Popup.get_text_by_extent(cursor.extent)
body = Popup.prettify_body(body)
popup.__text += BODY_TEMPLATE.format(
content=CODE_TEMPLATE.format(lang="c++", code=body))
return popup
Expand All @@ -184,6 +186,7 @@ def show(self, view, location=-1, on_navigate=None):
max_height=Popup.MAX_POPUP_HEIGHT,
wrapper_class=Popup.WRAPPER_CLASS,
css=self.CSS,
flags=sublime.HIDE_ON_MOUSE_MOVE_AWAY,
location=location,
on_navigate=on_navigate)

Expand Down Expand Up @@ -279,6 +282,19 @@ def get_text_by_extent(extent):
lines = f.readlines()
return "".join(lines[extent.start.line - 1:extent.end.line])

@staticmethod
def prettify_body(body):
"""Format some declaration body for viewing.
Args:
body (str): Body text.
"""
# remove any global indentation
import textwrap
body = textwrap.dedent(body)

return body

@staticmethod
def info_objc(cursor):
"""Provide information about cursor to Objective C message expression.
Expand Down

0 comments on commit a19ecdd

Please sign in to comment.