Skip to content

Commit 07b2fdb

Browse files
committed
cu
1 parent 005ce22 commit 07b2fdb

3 files changed

Lines changed: 27 additions & 11 deletions

File tree

lua/fittencode/_types.lua

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
---@field cause? FittenCode.Error @错误原因
55
---@field metadata? table<string, any> @附加信息
66

7+
---@alias FittenCode.Encoding
8+
---| "utf-8" # UTF8
9+
---| "utf-16" # UTF16
10+
---| "utf-32" # UTF32
11+
712
---@class FittenCode.HTTP.RequestOptions
813
---@field method? string @HTTP 方法 (默认: 'GET')
914
---@field headers? table<string, string> @请求头

lua/fittencode/base/fn.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ function M.ignoreevent_wrap(fx, ignore)
186186

187187
vim.o.eventignore = ignore
188188

189-
-- 这里必须是 check_call
189+
-- 这里必须是 check_call,且 fx 里不应有 schedule
190190
local ret = Common.check_call(fx)
191191

192192
vim.schedule(function()

lua/fittencode/base/position.lua

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
--[[
22
3+
与显示无关的抽象位置对象。
4+
cu
5+
- UTF-8 8-bit byte
6+
- UTF-16 16-bit
7+
- UTF-32 32-bit
8+
39
]]
410

511
local Format = require('fittencode.base.format')
612

713
---@class FittenCode.Position
8-
---@field line number A zero-based row value.
9-
---@field cu number A zero-based column value.
14+
---@field line number A zero-based line value.
15+
---@field cu number A zero-based codeunit value.
16+
---@field encoding? FittenCode.Encoding
1017
local Position = {}
1118
Position.__index = Position
1219

@@ -22,7 +29,8 @@ function Position.new(options)
2229
end
2330

2431
function Position:__tostring()
25-
return Format.nothrow_format('Position<{}:{}>', self.line, self.cu)
32+
return Format.nothrow_format('({},{})', self.line, self.cu)
33+
-- return Format.nothrow_format('Position[line:{} cu:{}]', self.line, self.cu)
2634
end
2735

2836
-- Check if this position is equal to `other`.
@@ -86,9 +94,9 @@ function Position:compare_to(other)
8694
end
8795

8896
-- Create a new position relative to this position.
89-
---@param line_delta? number The number of rows to move.
90-
---@param cu_delta? number The number of columns to move.
91-
---@return FittenCode.Position The new position.
97+
---@param line_delta? number The number of lines to move.
98+
---@param cu_delta? number The number of codeunits to move.
99+
---@return FittenCode.Position
92100
function Position:translate(line_delta, cu_delta)
93101
return Position.new({
94102
line = self.line + (line_delta or 0),
@@ -97,9 +105,9 @@ function Position:translate(line_delta, cu_delta)
97105
end
98106

99107
-- Create a new position derived from this position.
100-
---@param line? number The new row value.
101-
---@param cu? number The new column value.
102-
---@return FittenCode.Position The new position.
108+
---@param line? number The new line value.
109+
---@param cu? number The new codeunit value.
110+
---@return FittenCode.Position
103111
function Position:with(line, cu)
104112
return Position.new({
105113
line = line or self.line,
@@ -108,7 +116,7 @@ function Position:with(line, cu)
108116
end
109117

110118
-- Create a copy of this position.
111-
---@return FittenCode.Position The new position.
119+
---@return FittenCode.Position
112120
function Position:clone()
113121
return Position.new({
114122
line = self.line,
@@ -130,6 +138,9 @@ function Position:rel_lastline()
130138
return self.line == -1
131139
end
132140

141+
---@param line number The new line value.
142+
---@param cu number The new codeunit value.
143+
---@return FittenCode.Position
133144
function Position.of(line, cu)
134145
return Position.new({
135146
line = line,

0 commit comments

Comments
 (0)