Skip to content

Conversation

gogongxt
Copy link

@gogongxt gogongxt commented Dec 27, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant