Skip to content

Commit 8c78935

Browse files
committed
clean up notes
1 parent a99b7c2 commit 8c78935

File tree

1 file changed

+1
-73
lines changed

1 file changed

+1
-73
lines changed

lua/plenary/path2.lua

Lines changed: 1 addition & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,6 @@
1-
--- NOTES:
2-
--- Rework on plenary.Path with a focus on better cross-platform support
3-
--- including 'shellslash' support.
4-
--- Effort to improve performance made (notably `:absolue` ~2x faster).
5-
---
6-
---
7-
--- BREAKING CHANGES:
8-
--- - `Path.new` no longer supported (think it's more confusing that helpful
9-
--- and not really used as far as I can tell)
10-
---
11-
--- - `Path.new` drops `sep` table param (eg. `Path:new {"foo\\bar/baz", sep = "/"}`)
12-
---
13-
--- - drop `__concat` metamethod? it was untested and had some todo comment,
14-
--- not sure how functional it is
15-
---
16-
--- - `Path` objects are now "read-only", I don't think people were ever doing
17-
--- things like `path.filename = 'foo'` but now explicitly adding some barrier
18-
--- to this. Allows us to compute `filename` from "metadata" parsed once on
19-
--- instantiation.
20-
---
21-
--- - FIX: `Path:make_relative` throws error if you try to make a path relative
22-
--- to another path that is not in the same subpath.
23-
---
24-
--- eg. `Path:new("foo/bar_baz"):make_relative("foo/bar")` => errors as you
25-
--- can't get to "foo/bar_baz" from "foo/bar" without going up in directory.
26-
--- This would previously return "foo/bar_baz" which is wrong.
27-
---
28-
--- Adds an option to walk up path to compensate.
29-
---
30-
--- eg. `Path:new("foo/bar_baz"):make_relative("foo/bar", true)` => returns
31-
--- "../bar_baz"
32-
---
33-
--- - error handling is generally more loud, ie. emit errors from libuv rather
34-
--- than swallowing it
35-
---
36-
--- - remove `Path:normalize`. It doesn't make any sense. eg. this test case
37-
--- ```lua
38-
--- it("can normalize ~ when file is within home directory (trailing slash)", function()
39-
--- local home = "/home/test/"
40-
--- local p = Path:new { home, "./test_file" }
41-
--- p.path.home = home
42-
--- p._cwd = "/tmp/lua"
43-
--- assert.are.same("~/test_file", p:normalize())
44-
--- end)
45-
--- ```
46-
--- if the idea is to make `/home/test/test_file` relative to `/tmp/lua`, the result
47-
--- should be `../../home/test/test_file`, only then can you substitue the
48-
--- home directory for `~`.
49-
--- So should really be `../../~/test_file`. But using `~` in a relative path
50-
--- like that looks weird to me. And as this function first makes paths
51-
--- relative, you will never get a leading `~` (since `~` literally
52-
--- represents the absolute path of the home directory).
53-
--- To top it off, something like `../../~/test_file` is impossible on Windows.
54-
--- `C:/Users/test/test_file` relative to `C:/Windows/temp` is
55-
--- `../../Users/test/test_file` and there's no home directory absolute path
56-
--- in this.
57-
---
58-
--- - `rename` returns new path rather than mutating path
59-
---
60-
--- - `copy`
61-
--- - drops interactive mode
62-
--- - return value table is pre-flattened
63-
--- - return value table value is `{success: boolean, err: string?}` rather than just `boolean`
64-
---
65-
--- - drops `check_self` mechanism (ie. doing `Path.read("some/file/path")`)
66-
--- seems unnecessary... just do `Path:new("some/file/path"):read()`
67-
---
68-
--- - renamed `iter` into `iter_lines` for more clarity
69-
---
70-
--- - `find_upwards` returns `nil` if file not found rather than an empty string
71-
72-
-- TODO: add windows test for path2_spec only?
73-
741
local bit = require "plenary.bit"
752
local uv = vim.loop
3+
764
local iswin = uv.os_uname().sysname == "Windows_NT"
775
local hasshellslash = vim.fn.exists "+shellslash" == 1
786

0 commit comments

Comments
 (0)