A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/neovim/neovim/commit/a5e475fcc269b32a8a487f787af20802cbfabe28 below:

start incremental sync range at previous newline character … · neovim/neovim@a5e475f · GitHub

File tree Expand file treeCollapse file tree 2 files changed

+36

-10

lines changed

Filter options

Expand file treeCollapse file tree 2 files changed

+36

-10

lines changed Original file line number Diff line number Diff line change

@@ -131,13 +131,22 @@ end

131 131

---@param offset_encoding string utf-8|utf-16|utf-32|nil (fallback to utf-8)

132 132

---@returns table<int, int> line_idx, byte_idx, and char_idx of first change position

133 133

local function compute_start_range(prev_lines, curr_lines, firstline, lastline, new_lastline, offset_encoding)

134 +

local char_idx

135 +

local byte_idx

134 136

-- If firstline == lastline, no existing text is changed. All edit operations

135 137

-- occur on a new line pointed to by lastline. This occurs during insertion of

136 138

-- new lines(O), the new newline is inserted at the line indicated by

137 139

-- new_lastline.

140 +

if firstline == lastline then

141 +

local line = prev_lines[firstline - 1]

142 +

byte_idx = #line + 1

143 +

char_idx = compute_line_length(line, offset_encoding) + 1

144 +

return { line_idx = firstline - 1, byte_idx = byte_idx, char_idx = char_idx }

145 +

end

146 + 138 147

-- If firstline == new_lastline, the first change occurred on a line that was deleted.

139 148

-- In this case, the first byte change is also at the first byte of firstline

140 -

if firstline == new_lastline or firstline == lastline then

149 +

if firstline == new_lastline then

141 150

return { line_idx = firstline, byte_idx = 1, char_idx = 1 }

142 151

end

143 152

@@ -158,8 +167,6 @@ local function compute_start_range(prev_lines, curr_lines, firstline, lastline,

158 167

end

159 168 160 169

-- Convert byte to codepoint if applicable

161 -

local char_idx

162 -

local byte_idx

163 170

if start_byte_idx == 1 or (#prev_line == 0 and start_byte_idx == 1)then

164 171

byte_idx = start_byte_idx

165 172

char_idx = 1

Original file line number Diff line number Diff line change

@@ -207,16 +207,16 @@ describe('incremental synchronization', function()

207 207

{

208 208

range = {

209 209

['start'] = {

210 -

character = 0,

211 -

line = 1

210 +

character = 11,

211 +

line = 0,

212 212

},

213 213

['end'] = {

214 214

character = 0,

215 215

line = 1

216 216

}

217 217

},

218 -

rangeLength = 0,

219 -

text = 'hello world\n'

218 +

rangeLength = 1,

219 +

text = '\nhello world\n'

220 220

}

221 221

}

222 222

test_edit({"hello world"}, {"yyp"}, expected_text_changes, 'utf-16', '\n')

@@ -226,19 +226,38 @@ describe('incremental synchronization', function()

226 226

{

227 227

range = {

228 228

['start'] = {

229 +

character = 11,

230 +

line = 0

231 +

},

232 +

['end'] = {

229 233

character = 0,

230 234

line = 1

235 +

}

236 +

},

237 +

rangeLength = 1,

238 +

text = '\n\n'

239 +

}

240 +

}

241 +

test_edit({"hello world"}, {"o"}, expected_text_changes, 'utf-16', '\n')

242 +

end)

243 +

it('adding a line to an empty buffer', function()

244 +

local expected_text_changes = {

245 +

{

246 +

range = {

247 +

['start'] = {

248 +

character = 0,

249 +

line = 0

231 250

},

232 251

['end'] = {

233 252

character = 0,

234 253

line = 1

235 254

}

236 255

},

237 -

rangeLength = 0,

238 -

text = '\n'

256 +

rangeLength = 1,

257 +

text = '\n\n'

239 258

}

240 259

}

241 -

test_edit({"hello world"}, {"o"}, expected_text_changes, 'utf-16', '\n')

260 +

test_edit({""}, {"o"}, expected_text_changes, 'utf-16', '\n')

242 261

end)

243 262

end)

244 263

describe('multi line edit', function()

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4