diff options
-rw-r--r-- | server/src/service.lua | 20 | ||||
-rw-r--r-- | server/src/workspace.lua | 11 |
2 files changed, 27 insertions, 4 deletions
diff --git a/server/src/service.lua b/server/src/service.lua index 94669218..1e97cb5c 100644 --- a/server/src/service.lua +++ b/server/src/service.lua @@ -184,6 +184,15 @@ function mt:isDeadText(uri) end function mt:open(uri, version, text) + if self.workspace then + local fileName = self.workspace:uriDecode(uri) + if not self.workspace:isLuaFile(fileName) then + return + end + if self.workspace.gitignore(fileName:string()) then + log.debug('Open ignored file:', fileName:string()) + end + end self:saveText(uri, version, text) local obj = self._file[uri] if obj then @@ -196,6 +205,17 @@ function mt:close(uri) if obj then obj._openByClient = false end + if self.workspace then + local fileName = self.workspace:uriDecode(uri) + if not self.workspace:isLuaFile(fileName) then + self:removeText(uri) + return + end + if self.workspace.gitignore(fileName:string()) then + log.debug('Close ignored file:', fileName:string()) + self:removeText(uri) + end + end end function mt:isOpen(uri) diff --git a/server/src/workspace.lua b/server/src/workspace.lua index c701bfa9..605c216c 100644 --- a/server/src/workspace.lua +++ b/server/src/workspace.lua @@ -3,6 +3,7 @@ local async = require 'async' local config = require 'config' local ll = require 'lpeglabel' local platform = require 'bee.platform' +local glob = require 'glob' local TrueName = {} @@ -155,16 +156,18 @@ function mt:scanFiles() end local pattern = self:buildScanPattern() - log.info('忽略文件:\r\n' .. table.concat(pattern, '\r\n')) + local options = { + ignoreCase = platform.OS == 'Windows', + } + log.info('ignore pattern:\r\n' .. table.concat(pattern, '\r\n')) + log.info('ignore options:' .. table.dump(options)) log.info('开始扫描文件任务') + self.gitignore = glob.gitignore(pattern, options) self._currentScanCompiled = {} local count = 0 self._scanRequest = async.run('scanfiles', { root = self.root:string(), pattern = pattern, - options = { - ignoreCase = platform.OS == 'Windows', - } }, function (mode, ...) if mode == 'ok' then log.info('扫描文件任务完成,共', count, '个文件。') |