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

'after' decoration type shown before cursor #91178

Closed
kieferrm opened this issue Feb 21, 2020 · 1 comment
Closed

'after' decoration type shown before cursor #91178

kieferrm opened this issue Feb 21, 2020 · 1 comment
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug editor-rendering Editor rendering issues verified Verification succeeded
Milestone

Comments

@kieferrm
Copy link
Member

VS Code version:
1.43.0-insider
e6a45f4
x64

I use the following extension code. (Also available at https://github.com/kieferrm/testplan-items/tree/master/editor-decorations.)

import * as vscode from 'vscode';

export function activate(context: vscode.ExtensionContext) {

	const beforeType = vscode.window.createTextEditorDecorationType({
		before: {
			contentText: 'before',
			color: '#e54910'
		}
	});
	const afterType = vscode.window.createTextEditorDecorationType({
		after: {
			contentText: 'after',
			color: '#7ba7ce'
		}
	});


	let disposable = vscode.commands.registerCommand('extension.setBeforeDecoration', () => {
		const selection = vscode.window.activeTextEditor?.selection;
		const position = selection?.start
		if (position) {
			const range = new vscode.Range(position, position);
			vscode.window.activeTextEditor?.setDecorations(beforeType, [range]);
		}
	});
	context.subscriptions.push(disposable);
	
	disposable = vscode.commands.registerCommand('extension.setAfterDecoration', () => {
		const selection = vscode.window.activeTextEditor?.selection;
		const position = selection?.start
		if (position) {
			const range = new vscode.Range(position, position);
			vscode.window.activeTextEditor?.setDecorations(afterType, [range]);
		}
	});
	context.subscriptions.push(disposable);

	disposable = vscode.commands.registerCommand('extension.removeDecorations', () => {
		vscode.window.activeTextEditor?.setDecorations(beforeType, []);
		vscode.window.activeTextEditor?.setDecorations(afterType, []);
	});

	context.subscriptions.push(disposable);
}

export function deactivate() { }

Use the following input in an untitled editor:

aaa
test()
bbb

Put the cursor between the parentheses and

  1. Set Before Decoration
  2. Remove Decorations
  3. Set After Decoration
  4. and 3) create the same result, i.e. appear before the cursor. I'd expect 3) to appear after the cursor.
@alexdima alexdima added bug Issue identified by VS Code Team member as probable bug editor-rendering Editor rendering issues labels Feb 23, 2020
@alexdima
Copy link
Member

Good package.json to reproduce:

{
    "publisher": "alex",
    "name": "91178",
    "version": "0.0.0",
    "engines": {
        "vscode": "^1.0.0"
    },
    "activationEvents": [
        "*"
    ],
    "contributes": {
        "commands": [{
            "command": "extension.setBeforeDecoration",
            "title": "91178: Set Before Decoration"
        }, {
            "command": "extension.setAfterDecoration",
            "title": "91178: Set After Decoration"
        }, {
            "command": "extension.removeDecorations",
            "title": "91178: Remove Decorations"
        }]
    },
    "main": "index.js"
}

alexdima added a commit that referenced this issue Feb 23, 2020
@alexdima alexdima added this to the February 2020 milestone Feb 23, 2020
@JacksonKearl JacksonKearl added the verified Verification succeeded label Feb 28, 2020
@github-actions github-actions bot locked and limited conversation to collaborators Apr 8, 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

3 participants