Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cursor appears before decoration on empty lines #40127

Closed
nicksnyder opened this issue Dec 12, 2017 · 8 comments
Closed

Cursor appears before decoration on empty lines #40127

nicksnyder opened this issue Dec 12, 2017 · 8 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug editor-rendering Editor rendering issues verified Verification succeeded
Milestone

Comments

@nicksnyder
Copy link
Contributor

Extensions like Gitlens register a decoration that appears before each line.

For lines that have content in them, everything works as expected: if you click on the decoration the cursor is placed at the beginning of the line AFTER the decoration.

For lines that do not have any content, the cursor is place BEFORE the decoration. This behavior seems strange.

screen recording 2017-12-12 at 10 46 am

@vscodebot vscodebot bot added editor editor-core Editor basic functionality labels Dec 12, 2017
@eamodio
Copy link
Contributor

eamodio commented Dec 12, 2017

@nicksnyder does GitLens always display the annotations chopped like that (where the heatmap is going through the date)?

@nicksnyder
Copy link
Contributor Author

@eamodio it looks like a bug with gitlens. Filed gitkraken/vscode-gitlens#228

Broken configuration:

"gitlens.blame.file.lineHighlight.locations": [
        "gutter",
        "overviewRuler"
    ],
    "gitlens.annotations.file.gutter.compact": false,
    "gitlens.annotations.file.gutter.format": "[${author|20?}] ${message|20?} ${ago|14-}",

Working configuration

"gitlens.blame.file.lineHighlight.locations": [
        "gutter",
        "overviewRuler"
    ],
    "gitlens.annotations.file.gutter.compact": false,
    "gitlens.annotations.file.gutter.format": "${id} [${author|15?}] ${message|20?} ${ago|14-}",

You should be able to reproduce (the screencap is from mainThreadStorage.ts in vscode).

@nicksnyder
Copy link
Contributor Author

(even with a working configuration, the issue I reported here still exists)

@eamodio
Copy link
Contributor

eamodio commented Dec 12, 2017

@nicksnyder thanks!

@alexdima alexdima added bug Issue identified by VS Code Team member as probable bug editor-rendering Editor rendering issues and removed editor editor-core Editor basic functionality labels Dec 13, 2017
@alexdima alexdima added this to the April 2018 milestone Apr 18, 2018
@rebornix rebornix added the verified Verification succeeded label Apr 26, 2018
@rebornix
Copy link
Member

line-decoration

I'm still seeing the cursor showing up before the line decoration when the content is empty

@rebornix rebornix added verification-found Issue verification failed and removed verified Verification succeeded labels Apr 26, 2018
@alexdima alexdima reopened this Apr 27, 2018
@alexdima
Copy link
Member

Here is the extension I've tried with (which works for me):

  • package.json:
{
    "publisher": "alex",
    "name": "40127",
    "version": "0.0.0",
    "engines": {
        "vscode": "^1.0.0"
    },
    "activationEvents": [
        "*"
    ],
    "main": "index.js"
}
  • index.js:
const vscode = require('vscode');

exports.activate = function () {
	var dectype = vscode.window.createTextEditorDecorationType({
		before: {
			contentText: "1234567890",
			color: "#ff0000"
		}
	});
	vscode.window.activeTextEditor.setDecorations(dectype, [
		new vscode.Range(0, 0, 0, 0),
		new vscode.Range(1, 0, 1, 0),
		new vscode.Range(2, 0, 2, 0),
		new vscode.Range(3, 0, 3, 0),
		new vscode.Range(4, 0, 4, 0),
		new vscode.Range(5, 0, 5, 0),
		new vscode.Range(6, 0, 6, 0),
		new vscode.Range(7, 0, 7, 0),
		new vscode.Range(8, 0, 8, 0),
		new vscode.Range(9, 0, 9, 0),
	]);
}

kapture 2018-04-27 at 10 34 52

@eamodio Do these lines get both before and after inline decorations ?

@alexdima alexdima added info-needed Issue requires more information from poster and removed verification-found Issue verification failed labels Apr 27, 2018
@alexdima alexdima removed this from the April 2018 milestone Apr 27, 2018
@eamodio
Copy link
Contributor

eamodio commented Apr 27, 2018

@alexandrudima yeah, if you have the inline blame turned on, the selected line will also get an after at the end of the line.

@alexdima alexdima removed the info-needed Issue requires more information from poster label Apr 27, 2018
@alexdima
Copy link
Member

To verify:

  • package.json:
{
    "publisher": "alex",
    "name": "40127",
    "version": "0.0.0",
    "engines": {
        "vscode": "^1.0.0"
    },
    "activationEvents": [
        "*"
    ],
    "main": "index.js"
}
  • index.js:
const vscode = require('vscode');

exports.activate = function () {
	const dectype1 = vscode.window.createTextEditorDecorationType({
		before: {
			contentText: "1234567890",
			color: "#ff0000"
		}
	});
	vscode.window.activeTextEditor.setDecorations(dectype1, [
		new vscode.Range(0, 0, 0, 0),
		new vscode.Range(1, 0, 1, 0),
		new vscode.Range(2, 0, 2, 0),
		new vscode.Range(3, 0, 3, 0),
		new vscode.Range(4, 0, 4, 0),
		new vscode.Range(5, 0, 5, 0),
		new vscode.Range(6, 0, 6, 0),
		new vscode.Range(7, 0, 7, 0),
		new vscode.Range(8, 0, 8, 0),
		new vscode.Range(9, 0, 9, 0),
	]);
	const dectype2 = vscode.window.createTextEditorDecorationType({
		after: {
			contentText: "abcd",
			color: "#00ff00"
		}
	});
	vscode.window.activeTextEditor.setDecorations(dectype2, [
		new vscode.Range(0, 1000, 0, 1000),
		new vscode.Range(1, 1000, 1, 1000),
		new vscode.Range(2, 1000, 2, 1000),
		new vscode.Range(3, 1000, 3, 1000),
		new vscode.Range(4, 1000, 4, 1000),
		new vscode.Range(5, 1000, 5, 1000),
		new vscode.Range(6, 1000, 6, 1000),
		new vscode.Range(7, 1000, 7, 1000),
		new vscode.Range(8, 1000, 8, 1000),
		new vscode.Range(9, 1000, 9, 1000),
	]);
}

Have an empty line at the beginning of the file. The cursor and the indent guides should render precisely between the before and the after decoration:

image

@alexdima alexdima added this to the January 2020 milestone Jan 17, 2020
@jrieken jrieken added the verified Verification succeeded label Jan 30, 2020
@vscodebot vscodebot bot locked and limited conversation to collaborators Mar 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug editor-rendering Editor rendering issues verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

5 participants