Skip to content

Commit

Permalink
Merge pull request #175 from GeorgeTzellis/patch
Browse files Browse the repository at this point in the history
Line-highlighter highlights wrong line
  • Loading branch information
LeaVerou committed Aug 17, 2012
2 parents f9b7181 + 7303583 commit e339c86
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions code/editor.js
Expand Up @@ -429,10 +429,12 @@ var _ = window.Editor = function(pre) {
var highlighter = that.lineHighlight,
lines = (content.match(CRLF) || []).length,
line = (content.slice(0, ss).match(CRLF) || []).length,
lineHeight = parseFloat(getComputedStyle(this).height)/lines;
height = parseFloat(getComputedStyle(highlighter).height),
lineHeight = parseFloat(getComputedStyle(highlighter).lineHeight),
// To choose the rendered height, WebKit floors the lineHeight. Copy this behaviour
lineHeight = lineHeight === height? height : Math.floor(lineHeight);

highlighter.setAttribute('data-line', line + 1);
highlighter.style.height = lineHeight + 'px';
highlighter.style.top = line * lineHeight + 'px';
});

Expand Down
2 changes: 1 addition & 1 deletion style/style.css
Expand Up @@ -195,7 +195,7 @@ html.supports-range label.slider {
overflow: auto;
background: url(/img/noise.png), linear-gradient(left, hsl(24,20%,91%) 1px, transparent 1px) 2.8em 0 no-repeat;
background-color: hsl(24, 20%, 95%);
font: 100%/1.5 Monaco, Consolas, Inconsolata, 'Deja Vu Sans Mono', 'Droid Sans Mono', 'Andale Mono', 'Lucida Console', monospace;
font: 100%/1.5em Monaco, Consolas, Inconsolata, 'Deja Vu Sans Mono', 'Droid Sans Mono', 'Andale Mono', 'Lucida Console', monospace;
tab-size: 4;
word-wrap: normal;
text-shadow: 0 1px white;
Expand Down

0 comments on commit e339c86

Please sign in to comment.