nrepl-lazuli 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2439208ce1a3db5af7c886aa95b577bb713667461c92d129e997f378ca704926
4
- data.tar.gz: 6aabf3d36d3996ff158a2c50ebaa6239570e4799614a8d7110d50df7ca1ede4f
3
+ metadata.gz: eabdc5490b15f4402769dbdf5a21d3eb27e206df7a5e1effcbcd8d3d919ea9fa
4
+ data.tar.gz: f3d43cf6d6d1065f676147e87a03280d08fbe29bf28f9deeede58a8cfff126fd
5
5
  SHA512:
6
- metadata.gz: 755e29ac97e588baca03a48914cc968d23d96961c66c4a3778554bc29b2d14f05ac236f9d15a1b565318cab9a11c28bc1a07cf096911da656f1450c4ae52ac7f
7
- data.tar.gz: a6fabeadef479c719f9fa60b53587e85d0d25fd88e96a03311103b0a5a581cccb54425ebd68c9e75cb01e69335dc755631699153bb44501ec51d756d0dc693a8
6
+ metadata.gz: 49da53ef4958b719b6c46835431bdc8cbc78a5d0624d28b88994b8589ffcfd06c71fb5d44056ee1af4ec73a49a8dcadab3d03c0d3b88d6882f6df5f5a1a8386f
7
+ data.tar.gz: fb81f3e46cd3e4ec8a5b2da284b5310d3da694ec552cd3246722b19f9a57fa4404e0998faee52c63db760d9cf009fbbb0b788a0ee30c944eb8d236a322fa9dec
@@ -87,13 +87,42 @@ module NREPL
87
87
  'status' => ['done', 'interrupted'],
88
88
  'op' => msg['op']
89
89
  }))
90
-
91
90
  else
92
91
  send_msg(response_for(msg, {
93
92
  'status' => ['done'],
94
93
  'op' => msg['op']
95
94
  }))
96
95
  end
96
+ when 'update_watch_lines'
97
+ msg['id'] ||= "eval_#{@counter += 1}"
98
+ file = msg['file']
99
+ initial_line = msg['line']
100
+ delta = msg['delta']
101
+ rows_bindings = @bindings[file] || {}
102
+ rows_bindings.keys.each do |row|
103
+ if row > initial_line
104
+ watch = rows_bindings.delete(row)
105
+ new_row = row + delta
106
+ old_id = "#{file}:#{row+1}"
107
+ new_id = "#{file}:#{new_row+1}"
108
+
109
+ watch.keys.each do |id|
110
+ if id == old_id
111
+ watch_per_id = @bindings_by_id.delete(id)
112
+ @bindings_by_id[new_id] = watch_per_id.update(row: new_row)
113
+ else
114
+ @bindings_by_id[id][:row] = new_row
115
+ end
116
+ end
117
+ rows_bindings[new_row] = watch
118
+ old_binding = watch.delete(old_id)
119
+ watch[new_id] = old_binding if(old_binding)
120
+ end
121
+ end
122
+
123
+ get_watches(msg)
124
+ when 'get_watches'
125
+ get_watches(msg)
97
126
  when 'watches_for_file'
98
127
  msg['id'] ||= "eval_#{@counter += 1}"
99
128
  file = msg['file']
@@ -112,6 +141,22 @@ module NREPL
112
141
  end
113
142
  end
114
143
 
144
+ private def get_watches(msg)
145
+ msg['id'] ||= "eval_#{@counter += 1}"
146
+ file = msg['file']
147
+ rows_bindings = @bindings[file] || {}
148
+ watches = rows_bindings.flat_map do |row, watch|
149
+ watch.map do |id, _|
150
+ { 'file' => file, 'line' => row, 'id' => id }
151
+ end
152
+ end
153
+ send_msg(response_for(msg, {
154
+ 'status' => ['done'],
155
+ 'watches' => watches.sort_by { |w| w['line'] },
156
+ 'op' => msg['op']
157
+ }))
158
+ end
159
+
115
160
  private def eval_op(msg, stop)
116
161
  msg['id'] ||= "eval_#{@counter += 1}"
117
162
  id = msg['id']
@@ -174,7 +219,7 @@ module NREPL
174
219
  end
175
220
 
176
221
  private def evaluate_code(code, file, line, bind)
177
- bind ||= @@binding
222
+ bind ||= TOPLEVEL_BINDING.dup
178
223
  line = line ? line + 1 : 1
179
224
  eval(code, bind, file || "EVAL", line).inspect
180
225
  end
@@ -256,6 +301,3 @@ module NREPL
256
301
  end
257
302
  end
258
303
  end
259
-
260
- # To avoid locally binding with the NREPL::Connection module
261
- NREPL::Connection.class_variable_set(:@@binding, binding)
@@ -96,17 +96,20 @@ module NREPL
96
96
  def auto_create_bindings!
97
97
  dir_regex = Regexp.new("^#{Regexp.escape(@pwd)}")
98
98
  @call_trace = TracePoint.new(:class, :call) do |tp|
99
- id = "#{tp.path}:#{tp.lineno}"
99
+ path = tp.path
100
+ next if tp.path =~ /^(\<|.eval)/
101
+ path = File.join(@pwd, path) if File.dirname(path) == '.'
102
+ id = "#{path}:#{tp.lineno}"
100
103
  b = tp.binding
101
- @bindings_by_id[id] = {binding: b, file: tp.path, row: tp.lineno-1}
102
- @bindings[tp.path] ||= {}
103
- @bindings[tp.path][tp.lineno-1] ||= {}
104
- @bindings[tp.path][tp.lineno-1][id] = b
105
- if tp.path =~ dir_regex
104
+ @bindings_by_id[id] = {binding: b, file: path, row: tp.lineno-1}
105
+ @bindings[path] ||= {}
106
+ @bindings[path][tp.lineno-1] ||= {}
107
+ @bindings[path][tp.lineno-1][id] = b
108
+ if path =~ dir_regex
106
109
  @connections.each do |connection|
107
110
  connection.send_msg(
108
111
  'op' => 'hit_auto_watch',
109
- 'file' => tp.path,
112
+ 'file' => path,
110
113
  'line' => tp.lineno-1,
111
114
  'status' => ['done']
112
115
  )
data/lib/nrepl-lazuli.rb CHANGED
@@ -27,7 +27,7 @@ module NREPL
27
27
  'op' => 'hit_watch',
28
28
  'id' => id,
29
29
  'file' => file,
30
- 'line' => row,
30
+ 'line' => row - 1,
31
31
  'status' => ['done']
32
32
  )
33
33
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nrepl-lazuli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maurício Szabo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-07-11 00:00:00.000000000 Z
11
+ date: 2024-08-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bencode
@@ -38,7 +38,8 @@ files:
38
38
  homepage: https://gitlab.com/clj-editors/nrepl-lazuli
39
39
  licenses:
40
40
  - MIT
41
- metadata: {}
41
+ metadata:
42
+ source_code_uri: https://gitlab.com/clj-editors/nrepl-lazuli
42
43
  post_install_message:
43
44
  rdoc_options: []
44
45
  require_paths: