#1828 closed defect (fixed)
mimeviewer:tab_width in config is not work for browser
Reported by: | Owned by: | Matthew Good | |
---|---|---|---|
Priority: | normal | Milestone: | 0.9 |
Component: | version control/browser | Version: | devel |
Severity: | normal | Keywords: | |
Cc: | Branch: | ||
Release Notes: | |||
API Changes: | |||
Internal Changes: |
Description (last modified by )
On browsing source file, tab-width 8 is always used although specifying [mimeviewer] tab_width
.
I made a patch, but it may not correct fix.
-
api.py
216 216 candidates.append((qr, renderer)) 217 217 candidates.sort(lambda x,y: cmp(y[0], x[0])) 218 218 219 tab_width = int(self.config.get('mimeviewer', 'tab_width')) 220 221 if mimetype.lower().startswith('text/'): 222 content = content.expandtabs(tab_width) 223 219 224 for qr, renderer in candidates: 220 225 try: 221 226 self.log.debug('Trying to render HTML preview using %s' … … 226 231 elif isinstance(result, (str, unicode)): 227 232 return result 228 233 elif annotations: 229 return self._annotate(result, annotations )234 return self._annotate(result, annotations, tab_width) 230 235 else: 231 236 buf = StringIO() 232 237 buf.write('<div class="code-block"><pre>') 233 tab_width = int(self.config.get('mimeviewer', 'tab_width'))234 238 for line in result: 235 239 buf.write(line.expandtabs(tab_width) + '\n') 236 240 buf.write('</pre></div>') … … 239 243 self.log.warning('HTML preview using %s failed (%s)' 240 244 % (renderer, e), exc_info=True) 241 245 242 def _annotate(self, lines, annotations ):246 def _annotate(self, lines, annotations, tab_width): 243 247 buf = StringIO() 244 248 buf.write('<table class="code-block listing"><thead><tr>') 245 249 annotators = [] … … 259 263 div, mod = divmod(len(m), 2) 260 264 return div * ' ' + mod * ' ' 261 265 return (match.group('tag') or '') + ' ' 262 tab_width = int(self.config.get('mimeviewer', 'tab_width'))263 266 264 267 for num, line in enum(_html_splitlines(lines)): 265 268 cells = []
I'm using r2017. There's relating ticket:1655.
Attachments (0)
Change History (5)
comment:1 by , 19 years ago
Milestone: | → 0.9 |
---|---|
Owner: | changed from | to
Status: | new → assigned |
comment:2 by , 19 years ago
Description: | modified (diff) |
---|
comment:3 by , 19 years ago
Actually, no. The patch expands tabs before and after letting the renderer doing its job. Currently, the expansion is only done after the processing.
Is the pre-processing needed because the mimeviewer in question (which one is it?) expands tabs itself? If that's the case, we'll run into similar problems as those raised in #1920 about binary vs textual content. Simply checking for subtypes of text/
is not enough.
comment:4 by , 19 years ago
Owner: | changed from | to
---|---|
Status: | assigned → new |
cmlenz I'm gonna highjack this one.
The patch looks okay.