alefragnani/vscode-read-only-indicator

[FEATURE] - Read-only via vscode API (alternative mode)

zardoy opened this issue · 5 comments

Hi, I propose to add an alternative mode to extension so it uses vscode API, I believe it would resolve most of issue and make it work on the web:

// code that implements it
vscode.workspace.onDidChangeTextDocument(({ document, contentChanges }) => {
    const activeEditor = vscode.window.activeTextEditor
    if (activeEditor.document !== document || contentChanges.length === 0) return
    vscode.commands.executeCommand('undo')
    vscode.commands.executeCommand('editor.action.goToLocations', document.uri, new vscode.Position(0, 0), [], '', 'File is read-only')
})

image

Hi @zardoy ,

I'm not sure which issues are you referring to but, AFAIK, the workspace.fs API still doesn't work for remotes/web, as microsoft/vscode#48659 is still open. BTW, remote support is being tracked in #18.

But, if you have seen any OSS extension dealing with permissions on remotes, you could try applying the same approach here. And if it works, I would be happy with a PR.

Thank you

Hi, @alefragnani

I suggest to introduce a setting, so extension would interrup text changes within editor (as I understand this is the main goal of the extension) instead of touching files in FS, I also wonder how are you going to use vscode.workspace.fs API 🤔

The extension's purpose is not interrupt changes in the editor, but simply display if the current file permission (writable/read only). Ok, it also allows you to change that, but it does on a file system level, not simply the editor.

In fact, read only mode does not exist today in VS Code. Yes, some operations blocks editing, but an effective read only does not exists yet microsoft/vscode#4873.

In fact, read only mode does not exist today in VS Code. Yes, some operations blocks editing, but an effective read only does not exists yet microsoft/vscode#4873.

This is the exact reason is why I was looking for your extension, anyway thanks for clarifying the fact that this extension is for working with file permissions only.

No problem 👍