mirror of
https://github.com/atom/atom.git
synced 2026-01-23 13:58:08 -05:00
Merge branch 'master' into tree-massage
This commit is contained in:
@@ -242,12 +242,12 @@ describe "TextMateGrammar", ->
|
||||
expect(tokens[0].value).toBe "//"
|
||||
expect(tokens[1].value).toBe " a singleLineComment"
|
||||
|
||||
it "does not loop infinitley (regression)", ->
|
||||
it "does not loop infinitely (regression)", ->
|
||||
grammar = TextMateBundle.grammarForFilePath("hello.js")
|
||||
{tokens, ruleStack} = grammar.tokenizeLine("// line comment")
|
||||
{tokens, ruleStack} = grammar.tokenizeLine(" // second line comment with a single leading space", ruleStack)
|
||||
|
||||
describe "when inside an C block", ->
|
||||
describe "when inside a C block", ->
|
||||
it "correctly parses a method. (regression)", ->
|
||||
grammar = TextMateBundle.grammarForFilePath("hello.c")
|
||||
{tokens, ruleStack} = grammar.tokenizeLine("if(1){m()}")
|
||||
|
||||
@@ -383,3 +383,20 @@ describe "TokenizedBuffer", ->
|
||||
expect(tokens[0].scopes).toEqual ["source.c++", "meta.preprocessor.c.include"]
|
||||
expect(tokens[1].value).toBe 'include'
|
||||
expect(tokens[1].scopes).toEqual ["source.c++", "meta.preprocessor.c.include", "keyword.control.import.include.c"]
|
||||
|
||||
describe "when a Ruby source file is tokenized", ->
|
||||
beforeEach ->
|
||||
editSession = fixturesProject.buildEditSessionForPath('hello.rb', autoIndent: false)
|
||||
buffer = editSession.buffer
|
||||
tokenizedBuffer = editSession.displayBuffer.tokenizedBuffer
|
||||
editSession.setVisible(true)
|
||||
fullyTokenize(tokenizedBuffer)
|
||||
|
||||
afterEach ->
|
||||
editSession.destroy()
|
||||
|
||||
it "doesn't loop infinitely (regression)", ->
|
||||
expect(tokenizedBuffer.lineForScreenRow(0).text).toBe 'a = {'
|
||||
expect(tokenizedBuffer.lineForScreenRow(1).text).toBe ' "b" => "c",'
|
||||
expect(tokenizedBuffer.lineForScreenRow(2).text).toBe '}'
|
||||
expect(tokenizedBuffer.lineForScreenRow(3).text).toBe ''
|
||||
|
||||
3
spec/fixtures/hello.rb
vendored
Normal file
3
spec/fixtures/hello.rb
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
a = {
|
||||
"b" => "c",
|
||||
}
|
||||
@@ -759,6 +759,7 @@ class Editor extends View
|
||||
@underlayer.css('min-width', minWidth)
|
||||
@overlayer.css('min-width', minWidth)
|
||||
@layerMinWidth = minWidth
|
||||
@trigger 'editor:min-width-changed'
|
||||
|
||||
clearRenderedLines: ->
|
||||
@renderedLines.empty()
|
||||
|
||||
@@ -53,6 +53,7 @@ class TextMateGrammar
|
||||
|
||||
tokens.push(nextTokens...)
|
||||
position = tokensEndPosition
|
||||
break if position is line.length and nextTokens.length is 0
|
||||
|
||||
else # push filler token for unmatched text at end of line
|
||||
if position < line.length
|
||||
|
||||
@@ -19,15 +19,15 @@ class StatusBar extends View
|
||||
|
||||
@content: ->
|
||||
@div class: 'status-bar', =>
|
||||
@div class: 'file-info', =>
|
||||
@span class: 'git-branch', outlet: 'branchArea', =>
|
||||
@span class: 'octicons branch-icon'
|
||||
@span class: 'branch-label', outlet: 'branchLabel'
|
||||
@span class: 'git-status', outlet: 'gitStatusIcon'
|
||||
@span class: 'file-info', =>
|
||||
@span class: 'current-path', outlet: 'currentPath'
|
||||
@span class: 'buffer-modified', outlet: 'bufferModified'
|
||||
@div class: 'cursor-position', =>
|
||||
@span outlet: 'gitStatusIcon'
|
||||
@span outlet: 'branchArea', =>
|
||||
@span class: 'octicons branch-icon'
|
||||
@span class: 'branch-label', outlet: 'branchLabel'
|
||||
@span outlet: 'cursorPosition'
|
||||
@span class: 'cursor-position', outlet: 'cursorPosition'
|
||||
|
||||
|
||||
initialize: (@rootView, @editor) ->
|
||||
@updatePathText()
|
||||
@@ -76,7 +76,7 @@ class StatusBar extends View
|
||||
@gitStatusIcon.empty()
|
||||
return unless path
|
||||
|
||||
@gitStatusIcon.removeClass().addClass('octicons')
|
||||
@gitStatusIcon.removeClass().addClass('git-status octicons')
|
||||
if @buffer.getGit()?.isPathModified(path)
|
||||
@gitStatusIcon.addClass('modified-status-icon')
|
||||
else if @buffer.getGit()?.isPathNew(path)
|
||||
|
||||
@@ -10,6 +10,7 @@ describe "WrapGuide", ->
|
||||
rootView.attachToDom()
|
||||
editor = rootView.getActiveEditor()
|
||||
wrapGuide = rootView.find('.wrap-guide').view()
|
||||
editor.width(editor.charWidth * wrapGuide.defaultColumn * 2)
|
||||
|
||||
afterEach ->
|
||||
rootView.deactivate()
|
||||
@@ -27,6 +28,7 @@ describe "WrapGuide", ->
|
||||
width = editor.charWidth * wrapGuide.defaultColumn
|
||||
expect(width).toBeGreaterThan(0)
|
||||
expect(wrapGuide.position().left).toBe(width)
|
||||
expect(wrapGuide).toBeVisible()
|
||||
|
||||
describe "when the font size changes", ->
|
||||
it "updates the wrap guide position", ->
|
||||
@@ -34,6 +36,7 @@ describe "WrapGuide", ->
|
||||
expect(initial).toBeGreaterThan(0)
|
||||
rootView.trigger('window:increase-font-size')
|
||||
expect(wrapGuide.position().left).toBeGreaterThan(initial)
|
||||
expect(wrapGuide).toBeVisible()
|
||||
|
||||
describe "overriding getGuideColumn", ->
|
||||
it "invokes the callback with the editor path", ->
|
||||
@@ -41,7 +44,7 @@ describe "WrapGuide", ->
|
||||
wrapGuide.getGuideColumn = (path) ->
|
||||
editorPath = path
|
||||
80
|
||||
wrapGuide.updateGuide(editor)
|
||||
wrapGuide.updateGuide()
|
||||
expect(editorPath).toBe(require.resolve('fixtures/sample.js'))
|
||||
|
||||
it "invokes the callback with a default value", ->
|
||||
@@ -51,7 +54,7 @@ describe "WrapGuide", ->
|
||||
column = defaultColumn
|
||||
defaultColumn
|
||||
|
||||
wrapGuide.updateGuide(editor)
|
||||
wrapGuide.updateGuide()
|
||||
expect(column).toBeGreaterThan(0)
|
||||
|
||||
# this is disabled because we no longer support passing config to an extension
|
||||
@@ -68,5 +71,11 @@ describe "WrapGuide", ->
|
||||
it "hides the guide when the column is less than 1", ->
|
||||
wrapGuide.getGuideColumn = (path) ->
|
||||
-1
|
||||
wrapGuide.updateGuide(editor)
|
||||
wrapGuide.updateGuide()
|
||||
expect(wrapGuide).toBeHidden()
|
||||
|
||||
describe "when no lines exceed the guide column and the editor width is smaller than the guide column position", ->
|
||||
it "hides the guide", ->
|
||||
editor.width(10)
|
||||
wrapGuide.updateGuide()
|
||||
expect(wrapGuide).toBeHidden()
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
{View} = require 'space-pen'
|
||||
$ = require 'jquery'
|
||||
|
||||
module.exports =
|
||||
class WrapGuide extends View
|
||||
@@ -28,13 +29,18 @@ class WrapGuide extends View
|
||||
else
|
||||
@getGuideColumn = (path, defaultColumn) -> defaultColumn
|
||||
|
||||
@observeConfig 'editor.fontSize', => @updateGuide(@editor)
|
||||
@subscribe @editor, 'editor-path-change', => @updateGuide(@editor)
|
||||
@subscribe @editor, 'before-remove', => @rootView.off('.wrap-guide')
|
||||
@observeConfig 'editor.fontSize', => @updateGuide()
|
||||
@subscribe @editor, 'editor-path-change', => @updateGuide()
|
||||
@subscribe @editor, 'editor:min-width-changed', => @updateGuide()
|
||||
@subscribe $(window), 'resize', => @updateGuide()
|
||||
|
||||
updateGuide: (editor) ->
|
||||
column = @getGuideColumn(editor.getPath(), @defaultColumn)
|
||||
updateGuide: ->
|
||||
column = @getGuideColumn(@editor.getPath(), @defaultColumn)
|
||||
if column > 0
|
||||
@css('left', "#{editor.charWidth * column}px").show()
|
||||
columnWidth = @editor.charWidth * column
|
||||
if columnWidth < @editor.layerMinWidth or columnWidth < @editor.width()
|
||||
@css('left', "#{columnWidth}px").show()
|
||||
else
|
||||
@hide()
|
||||
else
|
||||
@hide()
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
color: #eee;
|
||||
-webkit-box-shadow: 0 0 5px 5px #222;
|
||||
padding: 5px;
|
||||
z-index: 99;
|
||||
}
|
||||
|
||||
.select-list ol {
|
||||
|
||||
@@ -1,37 +1,30 @@
|
||||
.status-bar {
|
||||
background: black;
|
||||
color: white;
|
||||
padding: 5px;
|
||||
background-image: -webkit-linear-gradient(#303030, #252525);
|
||||
border-top: 1px solid #454545;
|
||||
padding: 4px 10px 3px;
|
||||
font-size: 11px;
|
||||
line-height: 14px;
|
||||
color: #969696;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.status-bar .file-info {
|
||||
float: left;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.status-bar .cursor-position {
|
||||
position: absolute;
|
||||
right: 5px;
|
||||
top: 5px;
|
||||
padding-left: 10px;
|
||||
}
|
||||
|
||||
.status-bar .modified-status-icon {
|
||||
color: #6C6912;
|
||||
padding-right: 5px;
|
||||
.status-bar .git-branch {
|
||||
float: right;
|
||||
}
|
||||
|
||||
.status-bar .modified-status-icon:before {
|
||||
content: "\f26d";
|
||||
.status-bar .branch-label {
|
||||
padding-left: 5px;
|
||||
vertical-align: baseline;
|
||||
}
|
||||
|
||||
.status-bar .new-status-icon {
|
||||
color: #269F81;
|
||||
padding-right: 5px;
|
||||
}
|
||||
|
||||
.status-bar .new-status-icon:before {
|
||||
content: "\f26b";
|
||||
.status-bar .git-status.octicons {
|
||||
display: none;
|
||||
padding-left: 10px;
|
||||
margin-top:-2px;
|
||||
}
|
||||
|
||||
.status-bar .octicons {
|
||||
@@ -39,13 +32,31 @@
|
||||
font-size: 14px;
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
line-height: 14px;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.status-bar .branch-icon:before {
|
||||
content: "\f020";
|
||||
}
|
||||
|
||||
.status-bar .branch-label {
|
||||
padding-left: 5px;
|
||||
padding-right: 10px;
|
||||
.status-bar .git-status.octicons.modified-status-icon {
|
||||
color: #f78a46;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.status-bar .modified-status-icon:before {
|
||||
content: "\f26d";
|
||||
}
|
||||
|
||||
.status-bar .git-status.octicons.new-status-icon {
|
||||
color: #5293d8;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.status-bar .new-status-icon:before {
|
||||
content: "\f26b";
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user