* Revert "core syntax: strip the path from filename on syntax.get (#1168)"
This reverts commit af6c4bc152
.
The previous behavior was correct and allowed access to the full path for path-dependant syntaxes.
* Use `Doc.abs_filename` to obtain syntax when possible
This allows matching full paths in language syntaxes, but we lose the
possibility of matching the project root.
This commit is contained in:
parent
a01eba3fad
commit
d12a14869c
|
@ -44,7 +44,12 @@ end
|
||||||
|
|
||||||
function Doc:reset_syntax()
|
function Doc:reset_syntax()
|
||||||
local header = self:get_text(1, 1, self:position_offset(1, 1, 128))
|
local header = self:get_text(1, 1, self:position_offset(1, 1, 128))
|
||||||
local syn = syntax.get(self.filename or "", header)
|
local path = self.abs_filename
|
||||||
|
if not path and self.filename then
|
||||||
|
path = core.project_dir .. PATHSEP .. self.filename
|
||||||
|
end
|
||||||
|
if path then path = common.normalize_path(path) end
|
||||||
|
local syn = syntax.get(path or "", header)
|
||||||
if self.syntax ~= syn then
|
if self.syntax ~= syn then
|
||||||
self.syntax = syn
|
self.syntax = syn
|
||||||
self.highlighter:soft_reset()
|
self.highlighter:soft_reset()
|
||||||
|
|
|
@ -44,7 +44,7 @@ local function find(string, field)
|
||||||
end
|
end
|
||||||
|
|
||||||
function syntax.get(filename, header)
|
function syntax.get(filename, header)
|
||||||
return find(common.basename(filename), "files")
|
return find(filename, "files")
|
||||||
or (header and find(header, "headers"))
|
or (header and find(header, "headers"))
|
||||||
or plain_text_syntax
|
or plain_text_syntax
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue