mirror of
https://github.com/zyedidia/micro.git
synced 2026-03-29 14:22:42 +09:00
options: Add capability to define the line count parsed for the signature check
This commit is contained in:
@@ -766,9 +766,15 @@ func (b *Buffer) UpdateRules() {
|
||||
if length > 0 {
|
||||
signatureMatch := false
|
||||
if length > 1 {
|
||||
detectlimit := util.IntOpt(b.Settings["detectlimit"])
|
||||
lineCount := len(b.lines)
|
||||
limit := lineCount
|
||||
if detectlimit > 0 && lineCount > detectlimit {
|
||||
limit = detectlimit
|
||||
}
|
||||
for i := 0; i < length && !signatureMatch; i++ {
|
||||
if syntaxFiles[i].header.HasFileSignature() {
|
||||
for j := 0; j < 100 && !signatureMatch; j++ {
|
||||
for j := 0; j < limit && !signatureMatch; j++ {
|
||||
if syntaxFiles[i].header.MatchFileSignature(b.lines[j].data) {
|
||||
syntaxFile = syntaxFiles[i].fileName
|
||||
b.SyntaxDef = syntaxFiles[i].syntaxDef
|
||||
|
||||
@@ -44,6 +44,7 @@ func init() {
|
||||
var optionValidators = map[string]optionValidator{
|
||||
"autosave": validateNonNegativeValue,
|
||||
"clipboard": validateClipboard,
|
||||
"detectlimit": validateNonNegativeValue,
|
||||
"tabsize": validatePositiveValue,
|
||||
"scrollmargin": validateNonNegativeValue,
|
||||
"scrollspeed": validateNonNegativeValue,
|
||||
@@ -280,6 +281,7 @@ var defaultCommonSettings = map[string]interface{}{
|
||||
"basename": false,
|
||||
"colorcolumn": float64(0),
|
||||
"cursorline": true,
|
||||
"detectlimit": float64(100),
|
||||
"diffgutter": false,
|
||||
"encoding": "utf-8",
|
||||
"eofnewline": true,
|
||||
|
||||
Reference in New Issue
Block a user