diff --git a/package.json b/package.json index ffe6d30e0..bed93e845 100644 --- a/package.json +++ b/package.json @@ -72,7 +72,7 @@ "one-light-syntax": "1.2.0", "solarized-dark-syntax": "1.0.2", "solarized-light-syntax": "1.0.2", - "about": "1.5.0", + "about": "1.5.1", "archive-view": "0.61.1", "autocomplete-atom-api": "0.10.0", "autocomplete-css": "0.11.1", @@ -119,7 +119,7 @@ "wrap-guide": "0.38.1", "language-c": "0.51.3", "language-clojure": "0.20.0", - "language-coffee-script": "0.46.1", + "language-coffee-script": "0.47.0", "language-csharp": "0.12.1", "language-css": "0.36.1", "language-gfm": "0.86.0", @@ -127,7 +127,7 @@ "language-go": "0.42.0", "language-html": "0.44.1", "language-hyperlink": "0.16.0", - "language-java": "0.17.0", + "language-java": "0.18.0", "language-javascript": "0.110.0", "language-json": "0.18.0", "language-less": "0.29.3", @@ -140,7 +140,7 @@ "language-python": "0.43.1", "language-ruby": "0.68.5", "language-ruby-on-rails": "0.25.0", - "language-sass": "0.46.0", + "language-sass": "0.47.0", "language-shellscript": "0.21.1", "language-source": "0.9.0", "language-sql": "0.21.0", @@ -148,7 +148,7 @@ "language-todo": "0.27.0", "language-toml": "0.18.0", "language-xml": "0.34.5", - "language-yaml": "0.25.2" + "language-yaml": "0.26.0" }, "private": true, "scripts": { diff --git a/spec/atom-environment-spec.coffee b/spec/atom-environment-spec.coffee index 5fd4b11f1..846083b0e 100644 --- a/spec/atom-environment-spec.coffee +++ b/spec/atom-environment-spec.coffee @@ -28,8 +28,10 @@ describe "AtomEnvironment", -> atom.setSize(originalSize.width, originalSize.height) it 'sets the size of the window, and can retrieve the size just set', -> - atom.setSize(100, 400) - expect(atom.getSize()).toEqual width: 100, height: 400 + newWidth = originalSize.width + 12 + newHeight = originalSize.height + 23 + atom.setSize(newWidth, newHeight) + expect(atom.getSize()).toEqual width: newWidth, height: newHeight describe ".isReleasedVersion()", -> it "returns false if the version is a SHA and true otherwise", -> diff --git a/spec/git-repository-async-spec.js b/spec/git-repository-async-spec.js index 0442248e1..224280b39 100644 --- a/spec/git-repository-async-spec.js +++ b/spec/git-repository-async-spec.js @@ -103,7 +103,7 @@ describe('GitRepositoryAsync', () => { it('returns the repository path for a repository path', async () => { repo = openFixture('master.git') const repoPath = await repo.getPath() - expect(repoPath).toBe(path.join(__dirname, 'fixtures', 'git', 'master.git')) + expect(repoPath).toEqualPath(path.join(__dirname, 'fixtures', 'git', 'master.git')) }) }) diff --git a/spec/git-spec.coffee b/spec/git-spec.coffee index 3afd4da75..7d9e9bbd4 100644 --- a/spec/git-spec.coffee +++ b/spec/git-spec.coffee @@ -33,7 +33,7 @@ describe "GitRepository", -> waitsForPromise -> repo.async.getPath().then(onSuccess) runs -> - expect(onSuccess.mostRecentCall.args[0]).toBe(repoPath) + expect(onSuccess.mostRecentCall.args[0]).toEqualPath(repoPath) describe "new GitRepository(path)", -> it "throws an exception when no repository is found", -> diff --git a/spec/project-spec.coffee b/spec/project-spec.coffee index 7a6168ad5..17fea7360 100644 --- a/spec/project-spec.coffee +++ b/spec/project-spec.coffee @@ -526,7 +526,7 @@ describe "Project", -> expect(atom.project.getDirectories()[1].contains(inputPath)).toBe true expect(atom.project.relativizePath(inputPath)).toEqual [ atom.project.getPaths()[1], - 'somewhere/something.txt' + path.join('somewhere', 'something.txt') ] describe ".contains(path)", -> diff --git a/spec/spec-helper.coffee b/spec/spec-helper.coffee index 1194f2f76..9c4e09da0 100644 --- a/spec/spec-helper.coffee +++ b/spec/spec-helper.coffee @@ -172,8 +172,8 @@ jasmine.useRealClock = -> addCustomMatchers = (spec) -> spec.addMatchers toBeInstanceOf: (expected) -> - notText = if @isNot then " not" else "" - this.message = => "Expected #{jasmine.pp(@actual)} to#{notText} be instance of #{expected.name} class" + beOrNotBe = if @isNot then "not be" else "be" + this.message = => "Expected #{jasmine.pp(@actual)} to #{beOrNotBe} instance of #{expected.name} class" @actual instanceof expected toHaveLength: (expected) -> @@ -181,32 +181,38 @@ addCustomMatchers = (spec) -> this.message = => "Expected object #{@actual} has no length method" false else - notText = if @isNot then " not" else "" - this.message = => "Expected object with length #{@actual.length} to#{notText} have length #{expected}" + haveOrNotHave = if @isNot then "not have" else "have" + this.message = => "Expected object with length #{@actual.length} to #{haveOrNotHave} length #{expected}" @actual.length is expected toExistOnDisk: (expected) -> - notText = this.isNot and " not" or "" - @message = -> return "Expected path '" + @actual + "'" + notText + " to exist." + toOrNotTo = this.isNot and "not to" or "to" + @message = -> return "Expected path '#{@actual}' #{toOrNotTo} exist." fs.existsSync(@actual) toHaveFocus: -> - notText = this.isNot and " not" or "" + toOrNotTo = this.isNot and "not to" or "to" if not document.hasFocus() console.error "Specs will fail because the Dev Tools have focus. To fix this close the Dev Tools or click the spec runner." - @message = -> return "Expected element '" + @actual + "' or its descendants" + notText + " to have focus." + @message = -> return "Expected element '#{@actual}' or its descendants #{toOrNotTo} have focus." element = @actual element = element.get(0) if element.jquery element is document.activeElement or element.contains(document.activeElement) toShow: -> - notText = if @isNot then " not" else "" + toOrNotTo = this.isNot and "not to" or "to" element = @actual element = element.get(0) if element.jquery - @message = -> return "Expected element '#{element}' or its descendants#{notText} to show." + @message = -> return "Expected element '#{element}' or its descendants #{toOrNotTo} show." element.style.display in ['block', 'inline-block', 'static', 'fixed'] + toEqualPath: (expected) -> + actualPath = path.normalize(@actual) + expectedPath = path.normalize(expected) + @message = -> return "Expected path '#{actualPath}' to be equal to '#{expectedPath}'." + actualPath is expectedPath + window.waitsForPromise = (args...) -> label = null if args.length > 1 diff --git a/spec/text-editor-component-spec.js b/spec/text-editor-component-spec.js index d74d7ebd6..0fe1da5b2 100644 --- a/spec/text-editor-component-spec.js +++ b/spec/text-editor-component-spec.js @@ -4024,15 +4024,33 @@ describe('TextEditorComponent', function () { }) }) - describe('when changing the font', async function () { - it('measures the default char, the korean char, the double width char and the half width char widths', async function () { - expect(editor.getDefaultCharWidth()).toBeCloseTo(12, 0) + describe('when decreasing the fontSize', async function () { + it('decreases the widths of the korean char, the double width char and the half width char', async function () { + originalDefaultCharWidth = editor.getDefaultCharWidth() + koreanDefaultCharWidth = editor.getKoreanCharWidth() + doubleWidthDefaultCharWidth = editor.getDoubleWidthCharWidth() + halfWidthDefaultCharWidth = editor.getHalfWidthCharWidth() component.setFontSize(10) await nextViewUpdatePromise() - expect(editor.getDefaultCharWidth()).toBeCloseTo(6, 0) - expect(editor.getKoreanCharWidth()).toBeCloseTo(9, 0) - expect(editor.getDoubleWidthCharWidth()).toBe(10) - expect(editor.getHalfWidthCharWidth()).toBe(5) + expect(editor.getDefaultCharWidth()).toBeLessThan(originalDefaultCharWidth) + expect(editor.getKoreanCharWidth()).toBeLessThan(koreanDefaultCharWidth) + expect(editor.getDoubleWidthCharWidth()).toBeLessThan(doubleWidthDefaultCharWidth) + expect(editor.getHalfWidthCharWidth()).toBeLessThan(halfWidthDefaultCharWidth) + }) + }) + + describe('when increasing the fontSize', function() { + it('increases the widths of the korean char, the double width char and the half width char', async function () { + originalDefaultCharWidth = editor.getDefaultCharWidth() + koreanDefaultCharWidth = editor.getKoreanCharWidth() + doubleWidthDefaultCharWidth = editor.getDoubleWidthCharWidth() + halfWidthDefaultCharWidth = editor.getHalfWidthCharWidth() + component.setFontSize(25) + await nextViewUpdatePromise() + expect(editor.getDefaultCharWidth()).toBeGreaterThan(originalDefaultCharWidth) + expect(editor.getKoreanCharWidth()).toBeGreaterThan(koreanDefaultCharWidth) + expect(editor.getDoubleWidthCharWidth()).toBeGreaterThan(doubleWidthDefaultCharWidth) + expect(editor.getHalfWidthCharWidth()).toBeGreaterThan(halfWidthDefaultCharWidth) }) }) diff --git a/spec/text-editor-spec.coffee b/spec/text-editor-spec.coffee index 39124bb17..ecb7bd820 100644 --- a/spec/text-editor-spec.coffee +++ b/spec/text-editor-spec.coffee @@ -179,17 +179,19 @@ describe "TextEditor", -> expect(editor1.getLongTitle()).toBe "readme \u2014 sample-theme-1" expect(editor2.getLongTitle()).toBe "readme \u2014 sample-theme-2" - it "returns '' when opened files have identical file and dir names", -> + it "returns '' when opened files have identical file names in subdirectories", -> editor1 = null editor2 = null + path1 = path.join('sample-theme-1', 'src', 'js') + path2 = path.join('sample-theme-2', 'src', 'js') waitsForPromise -> - atom.workspace.open(path.join('sample-theme-1', 'src', 'js', 'main.js')).then (o) -> + atom.workspace.open(path.join(path1, 'main.js')).then (o) -> editor1 = o - atom.workspace.open(path.join('sample-theme-2', 'src', 'js', 'main.js')).then (o) -> + atom.workspace.open(path.join(path2, 'main.js')).then (o) -> editor2 = o runs -> - expect(editor1.getLongTitle()).toBe "main.js \u2014 sample-theme-1/src/js" - expect(editor2.getLongTitle()).toBe "main.js \u2014 sample-theme-2/src/js" + expect(editor1.getLongTitle()).toBe "main.js \u2014 #{path1}" + expect(editor2.getLongTitle()).toBe "main.js \u2014 #{path2}" it "returns '' when opened files have identical file and same parent dir name", -> editor1 = null @@ -201,7 +203,7 @@ describe "TextEditor", -> editor2 = o runs -> expect(editor1.getLongTitle()).toBe "main.js \u2014 js" - expect(editor2.getLongTitle()).toBe "main.js \u2014 js/plugin" + expect(editor2.getLongTitle()).toBe "main.js \u2014 " + path.join('js', 'plugin') it "notifies ::onDidChangeTitle observers when the underlying buffer path changes", -> observed = [] diff --git a/spec/theme-manager-spec.coffee b/spec/theme-manager-spec.coffee index ea0ca19e6..47b848809 100644 --- a/spec/theme-manager-spec.coffee +++ b/spec/theme-manager-spec.coffee @@ -175,7 +175,7 @@ describe "atom.themes", -> expect(styleElementAddedHandler).toHaveBeenCalled() element = document.querySelector('head style[source-path*="css.css"]') - expect(element.getAttribute('source-path')).toBe atom.themes.stringToId(cssPath) + expect(element.getAttribute('source-path')).toEqualPath atom.themes.stringToId(cssPath) expect(element.textContent).toBe fs.readFileSync(cssPath, 'utf8') # doesn't append twice @@ -194,7 +194,7 @@ describe "atom.themes", -> expect(document.querySelectorAll('head style').length).toBe lengthBefore + 1 element = document.querySelector('head style[source-path*="sample.less"]') - expect(element.getAttribute('source-path')).toBe atom.themes.stringToId(lessPath) + expect(element.getAttribute('source-path')).toEqualPath atom.themes.stringToId(lessPath) expect(element.textContent).toBe """ #header { color: #4d926f; @@ -213,9 +213,9 @@ describe "atom.themes", -> it "supports requiring css and less stylesheets without an explicit extension", -> atom.themes.requireStylesheet path.join(__dirname, 'fixtures', 'css') - expect(document.querySelector('head style[source-path*="css.css"]').getAttribute('source-path')).toBe atom.themes.stringToId(atom.project.getDirectories()[0]?.resolve('css.css')) + expect(document.querySelector('head style[source-path*="css.css"]').getAttribute('source-path')).toEqualPath atom.themes.stringToId(atom.project.getDirectories()[0]?.resolve('css.css')) atom.themes.requireStylesheet path.join(__dirname, 'fixtures', 'sample') - expect(document.querySelector('head style[source-path*="sample.less"]').getAttribute('source-path')).toBe atom.themes.stringToId(atom.project.getDirectories()[0]?.resolve('sample.less')) + expect(document.querySelector('head style[source-path*="sample.less"]').getAttribute('source-path')).toEqualPath atom.themes.stringToId(atom.project.getDirectories()[0]?.resolve('sample.less')) document.querySelector('head style[source-path*="css.css"]').remove() document.querySelector('head style[source-path*="sample.less"]').remove() diff --git a/spec/workspace-spec.coffee b/spec/workspace-spec.coffee index 4aeeb4183..6d53fb645 100644 --- a/spec/workspace-spec.coffee +++ b/spec/workspace-spec.coffee @@ -80,7 +80,8 @@ describe "Workspace", -> expect(untitledEditor.getText()).toBe("An untitled editor.") expect(atom.workspace.getActiveTextEditor().getPath()).toBe editor3.getPath() - expect(document.title).toMatch ///^#{path.basename(editor3.getLongTitle())}\ \u2014\ #{atom.project.getPaths()[0]}/// + pathEscaped = escapeStringRegex(atom.project.getPaths()[0]) + expect(document.title).toMatch ///^#{path.basename(editor3.getLongTitle())}\ \u2014\ #{pathEscaped}/// describe "where there are no open panes or editors", -> it "constructs the view with no open editors", -> @@ -833,25 +834,29 @@ describe "Workspace", -> describe "when there is an active pane item", -> it "sets the title to the pane item's title plus the project path", -> item = atom.workspace.getActivePaneItem() - expect(document.title).toMatch ///^#{item.getTitle()}\ \u2014\ #{atom.project.getPaths()[0]}/// + pathEscaped = escapeStringRegex(atom.project.getPaths()[0]) + expect(document.title).toMatch ///^#{item.getTitle()}\ \u2014\ #{pathEscaped}/// describe "when the title of the active pane item changes", -> it "updates the window title based on the item's new title", -> editor = atom.workspace.getActivePaneItem() editor.buffer.setPath(path.join(temp.dir, 'hi')) - expect(document.title).toMatch ///^#{editor.getTitle()}\ \u2014\ #{atom.project.getPaths()[0]}/// + pathEscaped = escapeStringRegex(atom.project.getPaths()[0]) + expect(document.title).toMatch ///^#{editor.getTitle()}\ \u2014\ #{pathEscaped}/// describe "when the active pane's item changes", -> it "updates the title to the new item's title plus the project path", -> atom.workspace.getActivePane().activateNextItem() item = atom.workspace.getActivePaneItem() - expect(document.title).toMatch ///^#{item.getTitle()}\ \u2014\ #{atom.project.getPaths()[0]}/// + pathEscaped = escapeStringRegex(atom.project.getPaths()[0]) + expect(document.title).toMatch ///^#{item.getTitle()}\ \u2014\ #{pathEscaped}/// describe "when the last pane item is removed", -> it "updates the title to contain the project's path", -> atom.workspace.getActivePane().destroy() expect(atom.workspace.getActivePaneItem()).toBeUndefined() - expect(document.title).toMatch ///^#{atom.project.getPaths()[0]}/// + pathEscaped = escapeStringRegex(atom.project.getPaths()[0]) + expect(document.title).toMatch ///^#{pathEscaped}/// describe "when an inactive pane's item changes", -> it "does not update the title", -> @@ -875,7 +880,8 @@ describe "Workspace", -> }) workspace2.deserialize(atom.workspace.serialize(), atom.deserializers) item = workspace2.getActivePaneItem() - expect(document.title).toMatch ///^#{item.getLongTitle()}\ \u2014\ #{atom.project.getPaths()[0]}/// + pathEscaped = escapeStringRegex(atom.project.getPaths()[0]) + expect(document.title).toMatch ///^#{item.getLongTitle()}\ \u2014\ #{pathEscaped}/// workspace2.destroy() describe "document edited status", -> @@ -1610,3 +1616,6 @@ describe "Workspace", -> runs -> expect(pane.getPendingItem()).toBeFalsy() + + escapeStringRegex = (str) -> + str.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&') diff --git a/src/text-editor-presenter.coffee b/src/text-editor-presenter.coffee index 3d69606aa..9b66c6312 100644 --- a/src/text-editor-presenter.coffee +++ b/src/text-editor-presenter.coffee @@ -474,19 +474,21 @@ class TextEditorPresenter pixelPosition = @pixelPositionForScreenPosition(screenPosition) - top = pixelPosition.top + @lineHeight - left = pixelPosition.left + @gutterWidth + # Fixed positioning. + top = @boundingClientRect.top + pixelPosition.top + @lineHeight + left = @boundingClientRect.left + pixelPosition.left + @gutterWidth if overlayDimensions = @overlayDimensions[decoration.id] {itemWidth, itemHeight, contentMargin} = overlayDimensions - rightDiff = left + @boundingClientRect.left + itemWidth + contentMargin - @windowWidth + rightDiff = left + itemWidth + contentMargin - @windowWidth left -= rightDiff if rightDiff > 0 - leftDiff = left + @boundingClientRect.left + contentMargin + leftDiff = left + contentMargin left -= leftDiff if leftDiff < 0 - if top + @boundingClientRect.top + itemHeight > @windowHeight and top - (itemHeight + @lineHeight) >= 0 + if top + itemHeight > @windowHeight and + top - (itemHeight + @lineHeight) >= 0 top -= itemHeight + @lineHeight pixelPosition.top = top diff --git a/static/text-editor-light.less b/static/text-editor-light.less index 7fafade1e..f5429fd7f 100644 --- a/static/text-editor-light.less +++ b/static/text-editor-light.less @@ -15,7 +15,7 @@ atom-text-editor[mini] { } atom-overlay { - position: absolute; + position: fixed; display: block; z-index: 4; }