More lsp stuff / telemetry-prep (#1694)

* more text document stuff

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* backend for rename and create etc

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates for functions

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* cleanup

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* js future

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* utils

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* cleanup send and sync shit

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* save the client

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* store the users privacy settings

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* bump version

Signed-off-by: Jess Frazelle <github@jessfraz.com>

---------

Signed-off-by: Jess Frazelle <github@jessfraz.com>
This commit is contained in:
Jess Frazelle
2024-03-12 13:37:47 -07:00
committed by GitHub
parent 73b7d3cc9d
commit 8b2bf00641
21 changed files with 358 additions and 102 deletions

View File

@ -21,14 +21,6 @@ function getIndentationCSS(level: number) {
return `calc(1rem * ${level + 1})`
}
// an OS-agnostic way to get the basename of the path.
export function basename(path: string): string {
// Regular expression to match the last portion of the path, taking into account both POSIX and Windows delimiters
const re = /[^\\/]+$/
const match = path.match(re)
return match ? match[0] : ''
}
function RenameForm({
fileOrDir,
setIsRenaming,
@ -156,7 +148,7 @@ const FileTreeItem = ({
level?: number
}) => {
const { send, context } = useFileContext()
const { lspClients } = useLspContext()
const { onFileOpen, onFileClose } = useLspContext()
const navigate = useNavigate()
const [isRenaming, setIsRenaming] = useState(false)
const [isConfirmingDelete, setIsConfirmingDelete] = useState(false)
@ -185,26 +177,8 @@ const FileTreeItem = ({
)
} else {
// Let the lsp servers know we closed a file.
const currentFilePath = basename(currentFile?.path || 'main.kcl')
lspClients.forEach((lspClient) => {
lspClient.textDocumentDidClose({
textDocument: {
uri: `file:///${currentFilePath}`,
},
})
})
const newFilePath = basename(fileOrDir.path)
// Then let the clients know we opened a file.
lspClients.forEach((lspClient) => {
lspClient.textDocumentDidOpen({
textDocument: {
uri: `file:///${newFilePath}`,
languageId: 'kcl',
version: 1,
text: '',
},
})
})
onFileClose(currentFile?.path || null, project?.path || null)
onFileOpen(fileOrDir.path, project?.path || null)
// Open kcl files
navigate(`${paths.FILE}/${encodeURIComponent(fileOrDir.path)}`)