Skip to content

Commit 2204547

Browse files
author
lexouduck
committed
fix: bugfix for the mdpopup display for macro doc comments
1 parent f9bf50c commit 2204547

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

plugin/error_vis/popups.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -190,24 +190,25 @@ def info(cursor, cindex, settings):
190190
popup.__text += Popup.__lookup_in_sublime_index(
191191
sublime.active_window(), cursor.spelling)
192192

193-
raw_comment = None
193+
has_comment = None
194194
if is_macro:
195-
raw_comment = macro_parser.doc_string
195+
has_comment = macro_parser.doc_string
196196
else:
197-
raw_comment = cursor.raw_comment
197+
has_comment = cursor.raw_comment
198198
# Doxygen comment: single-line brief description
199-
if raw_comment and cursor.brief_comment:
199+
if cursor.brief_comment or (is_macro and has_comment):
200200
popup.__text += BRIEF_DOC_TEMPLATE.format(
201201
content=CODE_TEMPLATE.format(lang="",
202202
code=cursor.brief_comment))
203203
# Doxygen comment: multi-line detailed description
204-
if raw_comment and cursor.raw_comment:
205-
clean_comment = Popup.cleanup_comment(cursor.raw_comment).strip()
204+
if cursor.raw_comment or (is_macro and has_comment):
205+
clean_comment = Popup.cleanup_comment(has_comment).strip()
206206
print(clean_comment)
207207
if clean_comment:
208208
# Only add this if there is a Doxygen comment.
209209
popup.__text += FULL_DOC_TEMPLATE.format(
210210
content=CODE_TEMPLATE.format(lang="", code=clean_comment))
211+
211212
# Show macro body
212213
if is_macro:
213214
body = "#define "

plugin/utils/macro_parser.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def _parse_macro_file_lines(self, macro_file_lines, macro_line_number):
6565
if (parser_state != 2) and re.match(r'^\s*//', prevline):
6666
parser_state = 1
6767
if (re.match(r'^\s*//[/!]', prevline)):
68-
self._raw_comment = prevline + "\n" + self._raw_comment
68+
self._raw_comment = prevline + self._raw_comment
6969
else:
7070
parser_state = 3
7171
log.debug("Error while parsing macro doc comment, " +
@@ -77,17 +77,17 @@ def _parse_macro_file_lines(self, macro_file_lines, macro_line_number):
7777
if (parser_state == 2):
7878
if re.match(r'^\s*/\*', prevline):
7979
if re.match(r'^\s*/\*[\*!]', prevline):
80-
self._raw_comment = prevline + "\n" + self._raw_comment
80+
self._raw_comment = prevline + self._raw_comment
8181
else:
8282
log.debug("Error while parsing macro doc comment, " +
8383
"found normal multi-line comment: " +
8484
self._raw_comment)
8585
parser_state = 0 if len(self._raw_comment) == 0 else 3
8686
else:
87-
self._raw_comment = prevline + "\n" + self._raw_comment
87+
self._raw_comment = prevline + self._raw_comment
8888
continue
8989
elif re.match(r'^\s*\*/', prevline):
90-
self._raw_comment = prevline + "\n" + self._raw_comment
90+
self._raw_comment = prevline + self._raw_comment
9191
parser_state = 2
9292
continue
9393
if (len(prevline) > 0):
@@ -119,7 +119,7 @@ def _parse_macro_file_lines(self, macro_file_lines, macro_line_number):
119119
while self._body.endswith("\\"):
120120
macro_line_number += 1
121121
line = macro_file_lines[macro_line_number - 1].rstrip()
122-
self._body += "\n" + line
122+
self._body += line
123123

124124
@property
125125
def args_string(self):

0 commit comments

Comments
 (0)