]> git.lizzy.rs Git - micro.git/commitdiff
Fix regressions in buffer settings initialization (#2035)
authorDmitry Maluka <dmitrymaluka@gmail.com>
Mon, 22 Feb 2021 23:18:37 +0000 (00:18 +0100)
committerGitHub <noreply@github.com>
Mon, 22 Feb 2021 23:18:37 +0000 (18:18 -0500)
Fix regressions after ba98b55:

- Unable to override filetype autodetection by setting a specific filetype
  for specific files, i.e. this doesn't work:

    "*.h": {
        "filetype": "c++"
    },

- Unable to enable/disable syntax highlighting for specific files,
  i.e. this doesn't work:

    "*.c": {
        "syntax": false
    },

- "readonly" setting doesn't work (neither global nor per-filetype).

internal/buffer/buffer.go

index 85470d83fdec63c44c5a441fb9b1bbc8eada2a32..7e0b808f323164c6ef26784ee7b88945077e5319 100644 (file)
@@ -304,11 +304,14 @@ func NewBuffer(r io.Reader, size int64, path string, startcursor Loc, btype BufT
                for k, v := range config.GlobalSettings {
                        if _, ok := config.DefaultGlobalOnlySettings[k]; !ok {
                                // make sure setting is not global-only
+                               settings[k] = v
                                b.Settings[k] = v
                        }
                }
-               b.Settings["readonly"] = settings["readonly"]
                config.InitLocalSettings(settings, path)
+               b.Settings["readonly"] = settings["readonly"]
+               b.Settings["filetype"] = settings["filetype"]
+               b.Settings["syntax"] = settings["syntax"]
 
                enc, err := htmlindex.Get(settings["encoding"].(string))
                if err != nil {