Skip to content

Formatting truncates output #43

@imamatory

Description

@imamatory

When call either Cljfmt or CljfmtRange on the whole buffer it truncates text.
Debugging the plugin with echo ended with wrong capturing fireplace#session_eval output
The function called with correct buffer content returns truncated result or redir behaves unexpectedly here:

let l:bufcontents = s:GetCurrentBufferContents()
redir => l:cljfmt_output
try
silent! call fireplace#session_eval(s:GetReformatString(l:bufcontents))
catch /^Clojure:.*/
redir END
throw "fmterr"
catch
redir END
throw v:exception
endtry
redir END
return s:FilterOutput(split(l:cljfmt_output, "\n"), 0)

Example of work:
Source

(ns battle-asserts.issues.array-transpose
  (:require [clojure.test.check.generators :as gen]))

(def level :easy)

(def description "Implement the matrix transposition function.
                  Matrices are presented as arrays of arrays, where internal arrays are rows of the matrix.
                  There are different ways to transpose a matrix:
                  1) reflect the array over its main diagonal (which runs from top-left to bottom-right);
                  2) write the rows of the original matrix as columns of the new one;
                 3) write the columns of the original matrix as rows of the new one.")

(defn signature []
  {:input [{:argument-name "arr1" :type {:name "array" :nested "integer"}}
           {:argument-name "arr2" :type {:name "array" :nested "integer"}}]
   :output {:type {:name "array" :nested {:name "array" :nested "integer"}}}})

(defn arguments-generator []
  (gen/tuple (gen/bind (gen/choose 2 5)
                       #(gen/vector (gen/vector gen/int %)))))

(def test-data
  [{:expected [[1 10] [2 20] [3 30]]
    :arguments [[[1 2 3] [10 20 30]]]}
   {:expected [[1 3 5] [2 4 6]]
    :arguments [[[1 2] [3 4] [5 6]]]}
   {:expected []
    :arguments [[]]}])

(defn solution [vectors]
  (if (not-empty vectors)
    (apply mapv vector vectors)
    []))

After fixing

(ns battle-asserts.issues.array-transpose
  (:require [clojure.test.check.generators :as gen]))

(def level :easy)

(def description "Implement the matrix transposition function.
                   Matrices are presented as arrays of arrays, where internal arrays are rows of the matrix.
                   There are different ways to transpose a matrix:
                   1) reflect the array over its main diagonal (which runs from top-left to bottom-right);
                   2) write the rows of the original matrix as columns of the new one;
                  3) write the columns of the original matrix as rows of the new one.")

(defn signature []
  {:input [{:argument-name "arr1" :type {:name "array" :nested "integer"}}
           {:argument-name "arr2" :type {:name "array" :nested "integer"}}]
   :output {:type {:name "array" :nested {:name "array" :nested "integer"}}}})

(defn arguments-generator []
  (gen/tuple (gen/bind (gen/choose 2 5)
                       #(gen/vector (gen/vector gen/int %)))))

(de

My ~/.lein/profiles.clj

{:user {:plugins [[cider/cider-nrepl "0.21.1"]
                  [jonase/eastwood "0.3.5"]
                  [lein-cljfmt "0.6.4"]]
        :dependenies [[cljfmt "0.6.4"]
                      [jonase/kibit "0.1.6" :exclusions [org.clojure/clojure]]]
        :repl-options {:init (require 'cljfmt.core)}
        }}

P.S. I have set up clojure environment first time and probably missed some points

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions