mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-09-21 07:58:04 +03:00
Observe the config
from tree view to show/hide git-ignored files
This commit is contained in:
parent
0a1b389994
commit
49d817a9c4
@ -129,8 +129,9 @@ describe "Project", ->
|
||||
expect(paths).not.toContain('a')
|
||||
expect(paths).toContain('b')
|
||||
|
||||
it "ignores files in gitignore for projects in a git tree", ->
|
||||
project.setHideIgnoredFiles(true)
|
||||
describe "when config.core.hideGitIgnoredFiles is true", ->
|
||||
it "ignores files that are present in .gitignore if the project is a git repo", ->
|
||||
config.core.hideGitIgnoredFiles = true
|
||||
project.setPath(require.resolve('fixtures/git/working-dir'))
|
||||
paths = null
|
||||
waitsForPromise ->
|
||||
@ -209,13 +210,3 @@ describe "Project", ->
|
||||
path: project.resolve('a')
|
||||
match: 'aa'
|
||||
range: [[1, 3], [1, 5]]
|
||||
|
||||
describe "hiding ignored files", ->
|
||||
it "defaults @hideIgnoredFiles to false", ->
|
||||
expect(project.getHideIgnoredFiles()).toBe(false)
|
||||
|
||||
it "implements a setter for the @hideIgnoredFiles option", ->
|
||||
project.setHideIgnoredFiles(true)
|
||||
expect(project.getHideIgnoredFiles()).toBe(true)
|
||||
project.setHideIgnoredFiles(false)
|
||||
expect(project.getHideIgnoredFiles()).toBe(false)
|
||||
|
@ -15,7 +15,6 @@ class Project
|
||||
autoIndent: true
|
||||
softTabs: true
|
||||
softWrap: false
|
||||
hideIgnoredFiles: false
|
||||
rootDirectory: null
|
||||
editSessions: null
|
||||
ignoredPathRegexes: null
|
||||
@ -71,7 +70,7 @@ class Project
|
||||
@ignoreRepositoryPath(path)
|
||||
|
||||
ignoreRepositoryPath: (path) ->
|
||||
@hideIgnoredFiles and @repo.isPathIgnored(fs.join(@getPath(), path))
|
||||
config.core.hideGitIgnoredFiles and @repo.isPathIgnored(fs.join(@getPath(), path))
|
||||
|
||||
resolve: (filePath) ->
|
||||
filePath = fs.join(@getPath(), filePath) unless filePath[0] == '/'
|
||||
@ -89,10 +88,6 @@ class Project
|
||||
getSoftWrap: -> @softWrap
|
||||
setSoftWrap: (@softWrap) ->
|
||||
|
||||
toggleIgnoredFiles: -> @setHideIgnoredFiles(not @hideIgnoredFiles)
|
||||
getHideIgnoredFiles: -> @hideIgnoredFiles
|
||||
setHideIgnoredFiles: (@hideIgnoredFiles) ->
|
||||
|
||||
buildEditSessionForPath: (filePath, editSessionOptions={}) ->
|
||||
@buildEditSession(@bufferForPath(filePath), editSessionOptions)
|
||||
|
||||
|
@ -90,7 +90,9 @@ class RootView extends View
|
||||
@command 'window:toggle-invisibles', =>
|
||||
config.editor.showInvisibles = not config.editor.showInvisibles
|
||||
config.update()
|
||||
@command 'window:toggle-ignored-files', => @toggleIgnoredFiles()
|
||||
@command 'window:toggle-ignored-files', =>
|
||||
config.core.hideGitIgnoredFiles = not config.core.hideGitIgnoredFiles
|
||||
config.update()
|
||||
|
||||
afterAttach: (onDom) ->
|
||||
@focus() if onDom
|
||||
@ -198,9 +200,6 @@ class RootView extends View
|
||||
updateWindowTitle: ->
|
||||
document.title = @title
|
||||
|
||||
toggleIgnoredFiles: ->
|
||||
@project.toggleIgnoredFiles()
|
||||
|
||||
getEditors: ->
|
||||
@panes.find('.pane > .editor').map(-> $(this).view()).toArray()
|
||||
|
||||
|
@ -851,20 +851,26 @@ describe "TreeView", ->
|
||||
waitsFor "directory view contens to refresh", ->
|
||||
treeView.root.entries.find('.entry').length == entriesCountBefore
|
||||
|
||||
describe "ignored files", ->
|
||||
describe "when config.core.hideGitIgnoredFiles is changed", ->
|
||||
[ignoreFile] = []
|
||||
|
||||
beforeEach ->
|
||||
ignoreFile = fs.join(require.resolve('fixtures/tree-view'), '.gitignore')
|
||||
fs.write(ignoreFile, 'tree-view.js')
|
||||
project.setHideIgnoredFiles(false)
|
||||
config.core.hideGitIgnoredFiles = false
|
||||
|
||||
afterEach ->
|
||||
fs.remove(ignoreFile) if fs.exists(ignoreFile)
|
||||
|
||||
it "toggles display of ignored path when setting is toggled", ->
|
||||
it "hides git-ignored files if the option is set, but otherwise shows them", ->
|
||||
expect(treeView.find('.file:contains(tree-view.js)').length).toBe 1
|
||||
rootView.trigger 'window:toggle-ignored-files'
|
||||
|
||||
config.core.hideGitIgnoredFiles = true
|
||||
config.update()
|
||||
|
||||
expect(treeView.find('.file:contains(tree-view.js)').length).toBe 0
|
||||
rootView.trigger 'window:toggle-ignored-files'
|
||||
|
||||
config.core.hideGitIgnoredFiles = false
|
||||
config.update()
|
||||
|
||||
expect(treeView.find('.file:contains(tree-view.js)').length).toBe 1
|
||||
|
@ -27,7 +27,7 @@ class DirectoryView extends View
|
||||
@directory.path
|
||||
|
||||
isPathIgnored: (path) ->
|
||||
@project.hideIgnoredFiles and @project.repo?.isPathIgnored(path)
|
||||
config.core.hideGitIgnoredFiles and @project.repo?.isPathIgnored(path)
|
||||
|
||||
buildEntries: ->
|
||||
@unwatchDescendantEntries()
|
||||
|
@ -66,8 +66,8 @@ class TreeView extends ScrollView
|
||||
@rootView.command 'tree-view:toggle', => @toggle()
|
||||
@rootView.command 'tree-view:reveal-active-file', => @revealActiveFile()
|
||||
@rootView.on 'active-editor-path-change', => @selectActiveFile()
|
||||
@rootView.on 'window:toggle-ignored-files', => @updateRoot()
|
||||
@rootView.project.on 'path-change', => @updateRoot()
|
||||
config.observe 'core.hideGitIgnoredFiles', (value) => @updateRoot()
|
||||
|
||||
@selectEntry(@root) if @root
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user