hlchunk.nvim icon indicating copy to clipboard operation
hlchunk.nvim copied to clipboard

bugfix: solve some time row is nil

Open gogongxt opened this issue 1 year ago • 0 comments

BUG:

Some times row will be nil and get follow error:

Error executing vim.schedule lua callback: ...e/nvim/lazy/hlchunk.nvim/lua/hlchunk/mods/chunk/init.lua:168: attempt to compare nil with number
stack traceback:
	...e/nvim/lazy/hlchunk.nvim/lua/hlchunk/mods/chunk/init.lua:168: in function 'fn'
	...re/nvim/lazy/hlchunk.nvim/lua/hlchunk/utils/loopTask.lua:63: in function 'fn'
	...share/nvim/lazy/hlchunk.nvim/lua/hlchunk/utils/timer.lua:16: in function <...share/nvim/lazy/hlchunk.nvim/lua/hlchunk/utils/timer.lua:15>

Recurrent the error:

I am not sure what is the source error.But when i open a c++ header file which formating with google style( class indent is one line), i move cursor between two chunk and i will get this error. Such as:

class Any {
 public:
  Any() = default;
  ~Any() = default;
  Any(const Any&) = delete;
  Any& operator=(const Any&) = delete;
  Any(Any&&) = default;
  Any& operator=(Any&&) = default;

  template <typename T>  // T:int    Derive<int>
  Any(T data) : base_(std::make_unique<Derive<T>>(data)) {}

  template <typename T>
  T cast_() {
    Derive<T>* pd = dynamic_cast<Derive<T>*>(base_.get());
    if (pd == nullptr) {
      throw "type is unmatch!";
    }
    return pd->data_;
  }

 private:
  class Base {
   public:
    virtual ~Base() = default;
  };

  template <typename T>
  class Derive : public Base {
   public:
    Derive(T data) : data_(data) {}
    T data_; 
  };

 private:
  std::unique_ptr<Base> base_;
};
image image image

gogongxt avatar Dec 27 '24 15:12 gogongxt