trice icon indicating copy to clipboard operation
trice copied to clipboard

Symbols such as `<` gets toggled between Unicode and symbol representation

Open dbeliavskij opened this issue 6 months ago • 4 comments

Describe the bug Having some trices in code with symbols < inside a format string, I noticed that these randomly switch between unicode representation and actual symbol representation:

Image

To Reproduce Add trices with < symbol, execute trice insert, perform other changes in code executing trice insert again until symbols change. I could not detect what exactly causes a switch and it does not happen every time.

Expected behavior Trices do not change without change to trice itself.

dbeliavskij avatar Jul 01 '25 12:07 dbeliavskij

This seems to be an editor display or OS issue. If the strings are modified, an other ID would get assigned. Please check out other editors like notepad++ and check the file encoding or BOM.

rokath avatar Jul 01 '25 13:07 rokath

The file encoding is UTF-8

I am not sure how the editor can be related. What I shoved in the screenshot is what change git sees in til.json file. The trices themselves in the code do not change, only their representation in til.json

dbeliavskij avatar Jul 01 '25 13:07 dbeliavskij

Currently no idea. For the conversion and file IO, library functions are used:


// toJSON converts lut into JSON byte slice in human-readable form.
func (lu TriceIDLookUp) toJSON() ([]byte, error) {
	return json.MarshalIndent(lu, "", "\t")
}

// toFile writes lut into file fn as indented JSON and in verbose mode helpers for third party.
func (ilu TriceIDLookUp) toFile(fSys afero.Fs, fn string) (err error) {
	var fJSON afero.File
	fJSON, err = fSys.Create(fn)
	msg.FatalOnErr(err)
	defer func() {
		err = fJSON.Close()
		msg.FatalOnErr(err)
	}()
	var b []byte
	b, err = ilu.toJSON()
	msg.FatalOnErr(err)
	_, err = fJSON.Write(b)
	msg.FatalOnErr(err)
	/////////
	return
}

rokath avatar Jul 01 '25 15:07 rokath

This issue has been automatically marked as stale because it has not had recent activity. Please update it if it is still relevant.

github-actions[bot] avatar Dec 05 '25 11:12 github-actions[bot]

There are now 2 tests in id/utf8_test.go. Closing this issue now. If the problem pops up again, please re-open, we can try to intensify those tests then to be able to catch and debug it.

rokath avatar Dec 12 '25 10:12 rokath