Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.

Commit c918b0b

Browse files
committed
Merge pull request #3849 from adobe/randy/issue-3478-again
Use integer line-height to avoid rounding differences
2 parents 6a8bcdb + 6bc0a9a commit c918b0b

2 files changed

Lines changed: 12 additions & 5 deletions

File tree

src/view/ViewCommandHandlers.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ define(function (require, exports, module) {
7575
* The ratio of line-height to font-size when they use the same units
7676
* @type {float}
7777
*/
78-
var LINE_HEIGHT = 1.3;
78+
var LINE_HEIGHT = 1.25;
7979

8080
/**
8181
* @private
@@ -171,7 +171,14 @@ define(function (require, exports, module) {
171171
var lhOld = parseFloat(lhStyle.substring(0, lhStyle.length - 2));
172172

173173
var fsNew = fsOld + (delta * adjustment);
174-
var lhNew = (fsUnits === lhUnits) ? fsNew * LINE_HEIGHT : lhOld;
174+
var lhNew = lhOld;
175+
if (fsUnits === lhUnits) {
176+
lhNew = fsNew * LINE_HEIGHT;
177+
if (lhUnits === "px") {
178+
// Use integer px value to avoid rounding differences
179+
lhNew = Math.ceil(lhNew);
180+
}
181+
}
175182

176183
var fsStr = fsNew + fsUnits;
177184
var lhStr = lhNew + lhUnits;

test/spec/ViewCommandHandlers-test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,11 @@ define(function (require, exports, module) {
121121
});
122122

123123
it("should keep the same font size when opening another document", function () {
124-
var promise, expectedSize, editor;
124+
var promise, originalSize, editor;
125125

126126
runs(function () {
127127
editor = EditorManager.getCurrentFullEditor();
128-
expectedSize = editor.getTextHeight() + 1;
128+
originalSize = editor.getTextHeight();
129129

130130
promise = CommandManager.execute(Commands.VIEW_INCREASE_FONT_SIZE);
131131
waitsForDone(promise, "Increase font size");
@@ -139,7 +139,7 @@ define(function (require, exports, module) {
139139

140140
runs(function () {
141141
editor = EditorManager.getCurrentFullEditor();
142-
expect(editor.getTextHeight()).toBe(expectedSize);
142+
expect(editor.getTextHeight()).toBeGreaterThan(originalSize);
143143
});
144144

145145
// This must be in the last spec in the suite.

0 commit comments

Comments
 (0)