summaryrefslogtreecommitdiff
path: root/chromium/tools/json_schema_compiler/code.py
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2020-10-12 14:27:29 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2020-10-13 09:35:20 +0000
commitc30a6232df03e1efbd9f3b226777b07e087a1122 (patch)
treee992f45784689f373bcc38d1b79a239ebe17ee23 /chromium/tools/json_schema_compiler/code.py
parent7b5b123ac58f58ffde0f4f6e488bcd09aa4decd3 (diff)
downloadqtwebengine-chromium-85-based.tar.gz
BASELINE: Update Chromium to 85.0.4183.14085-based
Change-Id: Iaa42f4680837c57725b1344f108c0196741f6057 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/tools/json_schema_compiler/code.py')
-rw-r--r--chromium/tools/json_schema_compiler/code.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/chromium/tools/json_schema_compiler/code.py b/chromium/tools/json_schema_compiler/code.py
index ef41cf88407..c23fc483c50 100644
--- a/chromium/tools/json_schema_compiler/code.py
+++ b/chromium/tools/json_schema_compiler/code.py
@@ -124,13 +124,18 @@ class Code(object):
def trim_comment(comment, max_len):
if len(comment) <= max_len:
return comment, ''
+ # If we ran out of space due to existing content, don't try to wrap.
+ if max_len <= 1:
+ return '', comment.lstrip()
last_space = comment.rfind(' ', 0, max_len + 1)
if last_space != -1:
line = comment[0:last_space]
comment = comment[last_space + 1:]
else:
- line = comment[0:max_len]
- comment = comment[max_len:]
+ # If the line can't be split, then don't try. The comments might be
+ # important (e.g. JSDoc) where splitting it breaks things.
+ line = comment
+ comment = ''
return line, comment.lstrip()
# First line has the full maximum length.
@@ -145,6 +150,7 @@ class Code(object):
# Any subsequent lines be subject to the wrap indent.
max_len = (self._comment_length - len(''.join(self._line_prefixes)) -
len(comment_prefix) - wrap_indent)
+ assert max_len > 1
while len(comment):
line, comment = trim_comment(comment, max_len)
self.Append(comment_prefix + (' ' * wrap_indent) + line, substitute=False)